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.Util.Trace
from iTasks.Internal.TaskStore import :: TaskOutputMessage(..)
from Testing.TestEvents import :: EndEventType
:: InteractiveTest
:: UnitTest
= { name :: String
, instructions :: String
, expectation :: String
, taskUnderTest :: Task ()
, test :: *World -> *(EndEventType,*World)
}
:: Test = UnitTest UnitTest
| InteractiveTest InteractiveTest
:: TestReport :== [(String,EndEventType)]
:: UnitTest
:: InteractiveTest
= { name :: String
, test :: *World -> *(TestResult,*World)
, instructions :: String
, expectation :: String
, taskUnderTest :: Task ()
}
:: TestSuite =
{ 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 class iTask InteractiveTest
derive JSONEncode UnitTest
derive JSONDecode UnitTest
......@@ -45,56 +27,27 @@ derive gEditor UnitTest
derive gText UnitTest
derive gDefault UnitTest
/**
* 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
assert :: String (a -> Bool) a -> UnitTest | 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
assertEqual :: String a a -> UnitTest | gEq{|*|} a & JSONEncode{|*|} 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
checkEqualWith :: (a a -> Bool) a a -> TestResult | gPrettyTrace{|*|} a
assertEqualWorld :: String a (*World -> *(a,*World)) -> UnitTest | gEq{|*|} a & JSONEncode{|*|} 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
/**
* 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
skip :: UnitTest -> UnitTest
/**
* Filter test suites based on the name of a test
*/
filterSuitesByTestName ::String [TestSuite] -> [TestSuite]
filterTestsByName :: String [Test] -> [Test]
filterTestsByName :: String [UnitTest] -> [UnitTest]
/**
* Test a specific editor
......@@ -114,8 +67,7 @@ testEditorWithShare :: (Editor a) a EditMode -> 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
......@@ -130,14 +82,4 @@ noneFailed :: TestReport -> Bool
* Runs the unit tests from the test suites and shows test
* results on stdout
*/
runUnitTestsCLI :: [TestSuite] *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
runUnitTests :: [UnitTest] *World -> *World
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.ReferenceImplementations
import qualified Data.Map as DM
import qualified Data.Set as DS
import Data.Maybe
derive gEq LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo
derive gPrettyTrace LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, JSONNode, Set, Maybe
derive gPrettyTrace UIChange, UIChildChange, UIAttributeChange, UI, UIType
derive JSONEncode LUI, LUIChanges, LUIEffects, LUIEffectStage, LUINo, Set
import Data.GenLexOrd
derive gLexOrd LUIEffectStage
......@@ -1659,4 +1659,4 @@ tests = applyUpstreamChangeTests
++ layoutSubUIsTests
++ 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