Copyright | (c) Christopher Wells, 2016 |
---|---|
License | MIT |
Maintainer | cwellsny@nycap.rr.com |
Safe Haskell | None |
Language | Haskell2010 |
- data Test = Test {}
- type TestResults = (Bool, String)
- runTest :: Test -> IO TestResults
- showResults :: Test -> TestResults -> String
Documentation
Represents a single test, with a name, a command, and an expected result.
type TestResults = (Bool, String) Source
Represents the results of a single test, including if it passed or failed, and the actual output.
runTest :: Test -> IO TestResults Source
Runs the command of a Test and checks to see if the output of the command is the same as the expected output of the Test.
If the result of running the command is equal to the expected result, then True will be returned. However, if the expected and actual results are not equal, then False will be returned.
The actual output of the test is also returned, so that it can be printed out in the case where the test fails.
>>>
runTest (Test "Hello" "echo 'Hello, World!'" "Hello, World!")
(True,"Hello, World!")
>>>
runTest (Test "Hello" "echo 'Goodbye, World!'" "Hello, World!")
(False,"Goodbye, World!")
showResults :: Test -> TestResults -> String Source
Returns a String showing the results of the Test. Includes the name of the Test and if it passed or failed.
>>>
let test = Test "HelloTest" "echo 'Hello, World!'" "Hello, World!"
>>>
result <- runTest test
>>>
showResults test result
"HelloTest: Passed"
>>>
let test = Test "GoodbyeTest" "echo 'Goodbye, World!'" "Hello, World!"
>>>
result <- runTest test
>>>
showResults test result
"GoodbyeTest: Failed\n Expected: Hello, World!\n Actual: Goodbye, World!"