Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for making assertions about test behavior.
Synopsis
- expectationFailure :: (HasCallStack, MonadThrow m) => String -> m a
- pending :: (HasCallStack, MonadThrow m) => m ()
- pendingWith :: (HasCallStack, MonadThrow m) => String -> m ()
- xit :: (HasCallStack, Monad m, MonadThrow m) => String -> ExampleT context m1 () -> SpecFree context m ()
- shouldFail :: (HasCallStack, MonadCatch m, MonadThrow m) => m () -> m ()
- shouldFailPredicate :: (HasCallStack, MonadCatch m, MonadThrow m) => (FailureReason -> Bool) -> m () -> m ()
- shouldThrow :: (HasCallStack, MonadThrow m, MonadCatch m, MonadIO m, Exception e) => m a -> (e -> Bool) -> m ()
- shouldBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m ()
- shouldNotBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m ()
- shouldContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m ()
- shouldContainPredicate :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> (a -> Bool) -> m ()
- shouldNotContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m ()
- shouldNotContainPredicate :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> (a -> Bool) -> m ()
- textShouldContain :: (HasCallStack, MonadThrow m) => Text -> Text -> m ()
- textShouldNotContain :: (HasCallStack, MonadThrow m) => Text -> Text -> m ()
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.
:: (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.