HMock-0.5.0.0: A flexible mock framework for testing effectful code.
Safe HaskellNone
LanguageHaskell2010

Test.HMock.MockMethod

Description

Functions to delegate Actions to HMock to match expectations. There is one delegation function that works if the return type has a Default instance, and another that doesn't require the Default instance, but causes the method to return undefined by default.

Synopsis

Documentation

mockMethod :: (HasCallStack, MonadIO m, MockableMethod cls name m r, Default r) => Action cls name m r -> MockT m r Source #

Implements a method in a Mockable monad by delegating to the mock framework. If the method is called unexpectedly, an exception will be thrown. However, an expected invocation without a specified response will return the default value.

mockDefaultlessMethod :: (HasCallStack, MonadIO m, MockableMethod cls name m r) => Action cls name m r -> MockT m r Source #

Implements a method in a Mockable monad by delegating to the mock framework. If the method is called unexpectedly, an exception will be thrown. However, an expected invocation without a specified response will return undefined. This can be used in place of mockMethod when the return type has no default.