Commit 533a5212 authored by Bas Lijnse's avatar Bas Lijnse

First step in updating test utilities to work with the new clean-test runner

parent b8c197af
definition module iTasks.Internal.Test.Definition definition module iTasks.Util.Testing
import iTasks import iTasks
import iTasks.Util.Trace import iTasks.Util.Trace
from iTasks.Internal.TaskStore import :: TaskOutputMessage(..) from iTasks.Internal.TaskStore import :: TaskOutputMessage(..)
from Testing.TestEvents import :: EndEventType
:: InteractiveTest :: UnitTest
= { name :: String = { name :: String
, instructions :: String , test :: *World -> *(EndEventType,*World)
, expectation :: String
, taskUnderTest :: Task ()
} }
:: Test = UnitTest UnitTest :: TestReport :== [(String,EndEventType)]
| InteractiveTest InteractiveTest
:: UnitTest :: InteractiveTest
= { name :: String = { name :: String
, test :: *World -> *(TestResult,*World) , instructions :: String
, expectation :: String
, taskUnderTest :: Task ()
} }
:: TestSuite = derive class iTask InteractiveTest
{ name :: String
, description :: String
, tests :: [Test]
}
:: TestResult
= Passed
| Failed !(Maybe String) //Observed behavior
| Skipped //The test was skipped
:: SuiteResult =
{ suiteName :: String
, testResults :: [(String,TestResult)]
}
:: TestReport :== [SuiteResult]
derive class iTask TestSuite, Test, InteractiveTest, TestResult, SuiteResult
derive JSONEncode UnitTest derive JSONEncode UnitTest
derive JSONDecode UnitTest derive JSONDecode UnitTest
...@@ -45,56 +27,27 @@ derive gEditor UnitTest ...@@ -45,56 +27,27 @@ derive gEditor UnitTest
derive gText UnitTest derive gText UnitTest
derive gDefault UnitTest derive gDefault UnitTest
/** assert :: String (a -> Bool) a -> UnitTest | JSONEncode{|*|} a
* Convenient wrapper for defining interactive tests
*
* @param The name of the test
* @param Instructions on how to execute the test
* @param A description of the expected results
* @param The task to test
*/
itest :: String String String (Task a) -> Test | iTask a
/** assertEqual :: String a a -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
* Convenient wrapper for defining unit tests
*
* @param The name of the test
* @param The task to test
*/
utest :: String (*World -> *(TestResult,*World)) -> Test
assert :: String (a -> Bool) a -> Test | gPrettyTrace{|*|} a
assertEqual :: String a a -> Test | gEq{|*|} a & gPrettyTrace{|*|} a
assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> Test | gPrettyTrace{|*|} a
assertEqualWorld :: String a (*World -> *(a,*World)) -> Test | gEq{|*|} a & gPrettyTrace{|*|} a assertWorld :: String (a -> Bool) (*World -> *(a,*World)) -> UnitTest | JSONEncode{|*|} a
checkEqual :: a a -> TestResult | gEq{|*|} a & gPrettyTrace{|*|} a assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & JSONEncode{|*|} a
checkEqualWith :: (a a -> Bool) a a -> TestResult | gPrettyTrace{|*|} a
pass :: String -> Test checkEqual :: a a -> EndEventType | gEq{|*|} a & JSONEncode{|*|} a
checkEqualWith :: (a a -> Bool) a a -> EndEventType | JSONEncode{|*|} a
fail :: String -> Test pass :: String -> UnitTest
skip :: Test -> Test fail :: String -> UnitTest
/** skip :: UnitTest -> UnitTest
* Convenient wrapper for defining test suites
*
* @param The name of the test suite
* @param A short description of the test suite
* @param The list of tests that make up the suite
*/
testsuite :: String String [Test] -> TestSuite
/** /**
* Filter test suites based on the name of a test * Filter test suites based on the name of a test
*/ */
filterTestsByName :: String [UnitTest] -> [UnitTest]
filterSuitesByTestName ::String [TestSuite] -> [TestSuite]
filterTestsByName :: String [Test] -> [Test]
/** /**
* Test a specific editor * Test a specific editor
...@@ -114,8 +67,7 @@ testEditorWithShare :: (Editor a) a EditMode -> Task a | iTask a ...@@ -114,8 +67,7 @@ testEditorWithShare :: (Editor a) a EditMode -> Task a | iTask a
*/ */
testCommonInteractions :: String -> Task a | iTask a testCommonInteractions :: String -> Task a | iTask a
//testTaskOutput :: String (Task a) [Either Event Int] [TaskOutputMessage] ([TaskOutputMessage] [TaskOutputMessage] -> TestResult) -> Test | iTask a
testTaskOutput :: String (Task a) [Either Event Int] [TaskOutputMessage] ([TaskOutputMessage] [TaskOutputMessage] -> TestResult) -> Test | iTask a
/** /**
* Test if all tests have passed * Test if all tests have passed
...@@ -130,14 +82,4 @@ noneFailed :: TestReport -> Bool ...@@ -130,14 +82,4 @@ noneFailed :: TestReport -> Bool
* Runs the unit tests from the test suites and shows test * Runs the unit tests from the test suites and shows test
* results on stdout * results on stdout
*/ */
runUnitTestsCLI :: [TestSuite] *World -> *World runUnitTests :: [UnitTest] *World -> *World
/**
* Run all unit tests from the test suites and dump
*/
runUnitTestsJSON :: [TestSuite] *World -> *World
/**
* Execute a set of tests as a separate program
* It writes the result of the test in an easily parsable format to the console
*/
execTestSuite :: TestSuite *World -> World
module iTasks.UI.Layout.UnitTests module iTasks.UI.Layout.UnitTests
import iTasks.UI.Layout.ReferenceImplementations import iTasks.Util.Testing
import iTasks.Internal.Test.Definition
import iTasks.UI.Layout import iTasks.UI.Layout
import iTasks.UI.Layout.ReferenceImplementations
import qualified Data.Map as DM import qualified Data.Map as DM
import qualified Data.Set as DS import qualified Data.Set as DS
import Data.Maybe import Data.Maybe
derive gEq LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo derive gEq LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo
derive gPrettyTrace LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, JSONNode, Set, Maybe derive JSONEncode LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, Set
derive gPrettyTrace UIChange, UIChildChange, UIAttributeChange, UI, UIType
import Data.GenLexOrd import Data.GenLexOrd
derive gLexOrd LUIEffectStage derive gLexOrd LUIEffectStage
...@@ -1659,4 +1659,4 @@ tests = applyUpstreamChangeTests ...@@ -1659,4 +1659,4 @@ tests = applyUpstreamChangeTests
++ layoutSubUIsTests ++ layoutSubUIsTests
++ combinationTests ++ combinationTests
Start w = runUnitTestsCLI [testsuite "Test.iTasks.UI.Layout" "Duh.." tests] w Start w = runUnitTests tests w
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment