test-framework-sandbox-0.1.1: test-sandbox support for the test-framework package

MaintainerBenjamin Surma <benjamin.surma@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Test.Framework.Providers.Sandbox

Contents

Description

test-framework interface for test-sandbox

Synopsis

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

sandboxTests Source #

Arguments

:: String

Name of the sandbox environment

-> [Sandbox Test]

Tests to perform

-> Test 

Executes tests in the Sandbox monad.

Test declaration

sandboxTest Source #

Arguments

:: String

Test name

-> Sandbox ()

Action to perform

-> Sandbox Test 

Creates a test from a Sandbox action. Any exception (or error thrown with throwError) will mark the test as failed.

sandboxTestGroup Source #

Arguments

:: String

Test group name

-> [Sandbox Test]

Tests to perform

-> Sandbox Test 

Groups tests in the Sandbox monad.

sandboxTestGroup' Source #

Arguments

:: 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.

yieldProgress Source #

Arguments

:: String

Text to display

-> Sandbox () 

Displays a progress update during a test.

withRetry :: SandboxRetry a => Int -> Sandbox a -> Sandbox a Source #