Maintainer | Benjamin Surma <benjamin.surma@gree.net> |
---|---|
Safe Haskell | None |
test-framework interface for test-sandbox
Introduction
This module interfaces the Test.Sandbox monad with the test-framework popular Haskell package for a unified test experience.
Tests share the same sandboxed environment: processes started in one test can be addressed in another. Variables can and should be used to pass information between test cases.
Usage example
The following example describes how the sed example from the Test.Sandbox would be crammed into the Test.Framework model.
Initialization of the Sandbox is performed by the sandboxTests
function. Tests are then individually declared by sandboxTest
and
grouped by sandboxTestGroup
.
import Test.Framework import Test.Framework.Providers.Sandbox import Test.Sandbox import Test.Sandbox.HUnit setup :: Sandbox () setup = start =<< register "sed_s/a/b/" "sed" [ "-u", "s/a/b/" ] def { psCapture = CaptureStdout } main = defaultMain [ sandboxTests "sed_tests" [ sandboxTest "setup" setup , sandboxTest "sed a->b" $ assertEqual "a->b" "b\n" =<< interactWith "sed_s/a/b/" "a\n" 5 , sandboxTest "sed aa->ba" $ assertEqual "aa->ba" "ba\n" =<< interactWith "sed_s/a/b/" "aa\n" 5 ] ]
Initialization
Executes tests in the Sandbox monad.
Test declaration
Creates a test from a Sandbox action. Any exception (or error thrown with throwError) will mark the test as failed.
Groups tests in the Sandbox monad.