system-test-0.1.2: Runs system tests of applications.

Copyright(c) Christopher Wells, 2016
LicenseMIT
Maintainercwellsny@nycap.rr.com
Safe HaskellNone
LanguageHaskell2010

SystemTest.Test

Description

 

Synopsis

Documentation

data Test Source

Represents a single test, with a name, a command, and an expected result.

Constructors

Test 

Fields

name :: String

The name of the Test.

command :: String

The command the to be run for the Test.

expectedOutput :: String

The expected result of the output of the command.

Instances

Show Test Source

Shows the contents of the values of the Test.

FromJSON Test Source

Converts JSON into Test.

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!"