Maintainer | Benjamin Surma <benjamin.surma@gmail.com> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
test-framework interface for test-sandbox
- sandboxTests :: String -> [Sandbox Test] -> Test
- sandboxTest :: String -> Sandbox () -> Sandbox Test
- sandboxTestGroup :: String -> [Sandbox Test] -> Sandbox Test
- sandboxTestGroup' :: String -> Sandbox Bool -> [Sandbox Test] -> Sandbox Test
- yieldProgress :: String -> Sandbox ()
- withRetry :: SandboxRetry a => Int -> Sandbox a -> Sandbox a
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.
:: String | Test group name |
-> Sandbox Bool | Condition for group to be evaluated |
-> [Sandbox Test] | Tests to perform if condition stands |
-> Sandbox Test |
Variant of sandboxTestGroup: tests will be skipped if the condition is not verified.
Displays a progress update during a test.