| License | BSD-3 |
|---|---|
| Maintainer | autotaker@gmail.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Method.Mock
Description
DSL to generate mock methods.
Synopsis
- type Mock method = Writer (MockSpec method) ()
- data MockSpec method
- mockup :: (Method method, MonadThrow (Base method)) => Mock method -> method
- thenReturn :: (Method method, Applicative (Base method)) => Matcher (Args method) -> Ret method -> Mock method
- thenAction :: Method method => Matcher (Args method) -> Base method (Ret method) -> Mock method
- thenMethod :: Method method => Matcher (Args method) -> method -> Mock method
- throwNoStubShow :: (Method method, Show (AsTuple (Args method)), MonadThrow (Base method), TupleLike (Args method)) => Matcher (Args method) -> Mock method
- throwNoStub :: (Method method, MonadThrow (Base method)) => (Args method -> String) -> (Args method -> Bool) -> Mock method
- newtype NoStubException = NoStubException String
Documentation
mockup :: (Method method, MonadThrow (Base method)) => Mock method -> method Source #
generate a method from Mock DSL. Mock DSL consists of rules. On a call of generated method, the first rule matched the arguments is applied.
thenReturn :: (Method method, Applicative (Base method)) => Matcher (Args method) -> Ret method -> Mock method Source #
matcher ` means the method return thenReturn` valuevalue
if the arguments matches matcher.
thenAction :: Method method => Matcher (Args method) -> Base method (Ret method) -> Mock method Source #
matcher ` means the method executes thenAction` actionaction
if the arguments matches matcher.
thenMethod :: Method method => Matcher (Args method) -> method -> Mock method Source #
matcher ` means the method call thenMethod` actionmethod with the arguments
if the arguments matches matcher.
throwNoStubShow :: (Method method, Show (AsTuple (Args method)), MonadThrow (Base method), TupleLike (Args method)) => Matcher (Args method) -> Mock method Source #
means the method throws a throwNoStubShow matcherNoStubException
if the arguments matches matcher. The argument tuple is converted to String by
using show function.
throwNoStub :: (Method method, MonadThrow (Base method)) => (Args method -> String) -> (Args method -> Bool) -> Mock method Source #
means the method throws a throwNoStubShow fshow matcherNoStubException
if the arguments matches matcher. The argument tuple is converted to String by
using fshow function.
newtype NoStubException Source #
Constructors
| NoStubException String |
Instances
| Show NoStubException Source # | |
Defined in Test.Method.Mock Methods showsPrec :: Int -> NoStubException -> ShowS # show :: NoStubException -> String # showList :: [NoStubException] -> ShowS # | |
| Exception NoStubException Source # | |
Defined in Test.Method.Mock Methods toException :: NoStubException -> SomeException # | |