hcltest-0.1: A testing library for command line applications.

Safe HaskellNone

Test.HClTest.Monad

Description

This module defines the basic test type, HClTest, which is a monad. It also provides functions for creating and running tests.

Synopsis

Documentation

newtype HClTest w a Source

The HClTest monad. A HClTest action describes a single test case. The first argument is the type of the trace entries. For tests, this should be Trace. For a single test step, this should be String.

Constructors

HClTest 

data Config Source

The config is passed in a Reader to the test cases.

Constructors

Config 

Instances

runHClTest :: Double -> HClTest Trace () -> IO (Bool, String)Source

Like runHClTestTrace, but already shows the trace so that you get a string.

runHClTestTrace :: Double -> HClTest Trace () -> IO (Bool, DList Trace)Source

Run a HClTest. The first argument is the timeout for waiting for output of the process, in milliseconds. The second argument is the test case.

This will run the test in a temporary working directory. Use the functions in Test.HClTest.Setup to setup the environment.

failTest :: a -> HClTest a bSource

This is a HClTest action that always fails. The first argument is the trace to leave. If you want to fail without leaving a trace, you can just use mzero.

testStep :: String -> HClTest String a -> HClTest Trace aSource

A single test step. The first argument is a description of the step. The test step can produce trace messages of type String. Those will be collected an exactly one Trace will be emitted.

traceMsg :: a -> HClTest a ()Source

Add a message to the log.

testIO :: String -> IO Bool -> HClTest Trace ()Source

Run an IO action, and fail if that action returns false. The first argument is a description of the IO action which will be used for the trace messages.

randomParallel :: Int -> [HClTest Trace ()] -> HClTest Trace ()Source

Run a number of tests in parallel, in random order. The first argument is the number of threads to use. Note that if the test cases require different working directories, some of the threads may block.

withWorkingDirectory :: FilePath -> HClTest Trace a -> HClTest Trace aSource

Run a test in the given directory.