tasty-process
is a library for running integration tests with the Tasty testing framework.
Features:
- Run an external process as a test case
- Supply input to
stdin
- Test the process'
exitcode
,stdout
andstderr
- Set timeout for the running process using Tasty's
Timeout
option - Automatic clean up the process after the test
Here is an example Echo program that reads from stdin
and echos back to stdout
.
module Main (main) where
main :: IO ()
main = getLine >>= putStr
And here is a test case for the Echo program using tasty-process
.
import System.Exit (ExitCode (..))
import Test.Tasty (TestTree)
import Test.Tasty.Process
echoTest :: TestTree
echoTest =
setTimeout (1000000) $ -- set timeout to 1 second
processTest
"Echo test" -- test name
TestProcess
{ process =
(proc "echo-test" []) -- process to launch with a list of arguments
, input = "Echo!" -- input to stdin
, exitCodeCheck = equals ExitSuccess -- check exit code
, stdoutCheck = equals "Echo!" -- check stdout
, stderrCheck = equals "" -- check stderr
}
See the Hackage page for detailed API documentation.
tasty-process
is tested with GHC version >= 8.6