sandwich-0.1.0.3: Yet another test framework for Haskell
Safe HaskellNone
LanguageHaskell2010

Test.Sandwich.Expectations

Description

Functions for making assertions about test behavior.

Synopsis

Manually fail a test or mark as pending

expectationFailure :: (HasCallStack, MonadThrow m) => String -> m a Source #

General-purpose function to throw a test exception with a String.

pending :: (HasCallStack, MonadThrow m) => m () Source #

Throws a Pending exception, which will cause the test to be marked as pending.

pendingWith :: (HasCallStack, MonadThrow m) => String -> m () Source #

Throws a Pending exception with a message to add additional details.

xit :: (HasCallStack, Monad m, MonadThrow m) => String -> ExampleT context m1 () -> SpecFree context m () Source #

Shorthand for a pending test example. You can quickly mark an it node as pending by putting an "x" in front of it.

Expecting failures

shouldFail :: (HasCallStack, MonadCatch m, MonadThrow m) => m () -> m () Source #

Assert that a given action should fail with some FailureReason.

shouldFailPredicate :: (HasCallStack, MonadCatch m, MonadThrow m) => (FailureReason -> Bool) -> m () -> m () Source #

Assert that a given action should fail with some FailureReason matching a predicate.

shouldThrow Source #

Arguments

:: (HasCallStack, MonadThrow m, MonadCatch m, MonadIO m, Exception e) 
=> m a

The action to run.

-> (e -> Bool)

A predicate on the exception to determine if it's as expected.

-> m () 

Asserts that an action should throw an exception. Accepts a predicate to determine if the exception matches.

Assertions

shouldBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m () Source #

Asserts that two things are equal.

shouldNotBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m () Source #

Asserts that two things are not equal.

shouldContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m () Source #

Asserts that the given list contains a subsequence.

shouldContainPredicate :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> (a -> Bool) -> m () Source #

Asserts that the given list contains an item matching a predicate.

shouldNotContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m () Source #

Asserts that the given list does not contain a subsequence.

shouldNotContainPredicate :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> (a -> Bool) -> m () Source #

Asserts that the given list contains an item matching a predicate.

textShouldContain :: (HasCallStack, MonadThrow m) => Text -> Text -> m () Source #

Asserts that the given text contains a substring.

textShouldNotContain :: (HasCallStack, MonadThrow m) => Text -> Text -> m () Source #

Asserts that the given text does not contain a substring.