planet-mitchell-test-0.0.0: Planet Mitchell

Safe HaskellNone
LanguageHaskell2010

Test

Contents

Synopsis

Running tests

defaultMain :: TestTree -> IO () #

Parse the command line arguments and run the tests.

When the tests finish, this function calls exitWith with the exit code that indicates whether any tests have failed. Most external systems (stack, cabal, travis-ci, jenkins etc.) rely on the exit code to detect whether the tests pass. If you want to do something else after defaultMain returns, you need to catch the exception and then re-throw it. Example:

import Test.Tasty
import Test.Tasty.HUnit
import System.Exit
import Control.Exception

test = testCase "Test 1" (2 @?= 3)

main = defaultMain test
  `catch` (\e -> do
    if e == ExitSuccess
      then putStrLn "Yea"
      else putStrLn "Nay"
    throwIO e)

defaultMainWithIngredients :: [Ingredient] -> TestTree -> IO () #

Parse the command line arguments and run the tests using the provided ingredient list.

When the tests finish, this function calls exitWith with the exit code that indicates whether any tests have failed. See defaultMain for details.

defaultIngredients :: [Ingredient] #

List of the default ingredients. This is what defaultMain uses.

At the moment it consists of listingTests and consoleTestReporter.

rerunningTests :: [Ingredient] -> Ingredient #

This Ingredient transformer adds various --rerun options to your test program. These flags add stateful execution of your test suite, allowing you to rerun only tests that are failing from the previous run, or tests that that have been added since the last test ran, once the TestTree has been filtered.

The input list of Ingredients specifies the Ingredientss that will actually work with the filtered TestTree. Normally, you'll want at least consoleTestReporter.

testGroup :: TestName -> [TestTree] -> TestTree #

Create a named group of test cases or other groups

Unit tests

testCase :: TestName -> Assertion -> TestTree #

Turn an Assertion into a tasty test case

shouldBe :: (HasCallStack, Show a, Eq a) => a -> a -> Expectation infix 1 #

actual `shouldBe` expected sets the expectation that actual is equal to expected.

shouldSatisfy :: (HasCallStack, Show a) => a -> (a -> Bool) -> Expectation infix 1 #

v `shouldSatisfy` p sets the expectation that p v is True.

shouldReturn :: (HasCallStack, Show a, Eq a) => IO a -> a -> Expectation infix 1 #

action `shouldReturn` expected sets the expectation that action returns expected.

Property tests

testProperty :: TestName -> Property -> TestTree #

Create a Test from a Hedgehog property

module Hedgehog