Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Functions for making assertions about test behavior.
Synopsis
- expectationFailure :: (HasCallStack, MonadIO m) => String -> m a
- pending :: (HasCallStack, MonadIO m) => m a
- pendingWith :: (HasCallStack, MonadIO m) => String -> m a
- xit :: (HasCallStack, MonadIO m) => String -> ExampleT context m1 () -> SpecFree context m ()
- shouldFail :: (HasCallStack, MonadUnliftIO m) => m () -> m ()
- shouldFailPredicate :: (HasCallStack, MonadUnliftIO m) => (FailureReason -> Bool) -> m () -> m ()
- shouldThrow :: (HasCallStack, MonadUnliftIO m, Exception e) => m a -> (e -> Bool) -> m ()
- shouldBe :: (HasCallStack, MonadIO m, Eq a, Show a) => a -> a -> m ()
- shouldNotBe :: (HasCallStack, MonadIO m, Eq a, Show a) => a -> a -> m ()
- shouldContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m ()
- shouldContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m ()
- shouldNotContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m ()
- shouldBeSet :: (HasCallStack, MonadIO m, Ord a, Show a) => [a] -> [a] -> m ()
- shouldNotContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m ()
- shouldBeNothing :: (HasCallStack, MonadIO m, Show a) => Maybe a -> m ()
- shouldBeJust :: (HasCallStack, MonadIO m) => Maybe a -> m ()
- shouldBeLeft :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m ()
- shouldBeRight :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m ()
- textShouldContain :: (HasCallStack, MonadIO m) => Text -> Text -> m ()
- textShouldNotContain :: (HasCallStack, MonadIO m) => Text -> Text -> m ()
Manually fail a test or mark as pending
expectationFailure :: (HasCallStack, MonadIO m) => String -> m a Source #
General-purpose function to throw a test exception with a String
.
pending :: (HasCallStack, MonadIO m) => m a Source #
Throws a Pending
exception, which will cause the test to be marked as pending.
pendingWith :: (HasCallStack, MonadIO m) => String -> m a Source #
Throws a Pending
exception with a message to add additional details.
xit :: (HasCallStack, MonadIO 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, MonadUnliftIO m) => m () -> m () Source #
Assert that a given action should fail with some FailureReason
.
shouldFailPredicate :: (HasCallStack, MonadUnliftIO m) => (FailureReason -> Bool) -> m () -> m () Source #
Assert that a given action should fail with some FailureReason
matching a predicate.
:: (HasCallStack, MonadUnliftIO 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, MonadIO m, Eq a, Show a) => a -> a -> m () Source #
Asserts that two things are equal.
shouldNotBe :: (HasCallStack, MonadIO m, Eq a, Show a) => a -> a -> m () Source #
Asserts that two things are not equal.
shouldContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m () Source #
Asserts that the given list contains a subsequence.
shouldContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m () Source #
Asserts that the given list contains an item matching a predicate.
shouldNotContain :: (HasCallStack, MonadIO m, Eq a, Show a) => [a] -> [a] -> m () Source #
Asserts that the given list does not contain a subsequence.
shouldBeSet :: (HasCallStack, MonadIO m, Ord a, Show a) => [a] -> [a] -> m () Source #
Asserts that the given lists are equal as sets.
shouldNotContainPredicate :: (HasCallStack, MonadIO m, Show a) => [a] -> (a -> Bool) -> m () Source #
Asserts that the given list contains an item matching a predicate.
shouldBeNothing :: (HasCallStack, MonadIO m, Show a) => Maybe a -> m () Source #
shouldBeJust :: (HasCallStack, MonadIO m) => Maybe a -> m () Source #
shouldBeLeft :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m () Source #
shouldBeRight :: (HasCallStack, MonadIO m, Show a, Show b) => Either a b -> m () Source #
textShouldContain :: (HasCallStack, MonadIO m) => Text -> Text -> m () Source #
Asserts that the given text contains a substring.
textShouldNotContain :: (HasCallStack, MonadIO m) => Text -> Text -> m () Source #
Asserts that the given text does not contain a substring.