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

Test.HMock.TH

Description

This module provides Template Haskell splices that can be used to derive boilerplate instances for HMock. makeMockable implements the common case where you just want to generate everything you need to mock with a class. The variant makeMockableWithOptions is similar, but takes an options parameter that can be used to customize the generation.

Synopsis

Documentation

data MakeMockableOptions Source #

Custom options for deriving MockableBase and related instances.

Constructors

MakeMockableOptions 

Fields

  • mockEmptySetup :: Bool

    Whether to generate a Mockable instance with an empty setup. If this is False, you are responsible for providing a Mockable instance. Defaults to True.

    If this is False, you are responsible for providing a Mockable instance as follows:

    instance Mockable MyClass where
      setupMockable _ = ...
    
  • mockDeriveForMockT :: Bool

    Whether to derive instances of the class for MockT or not. Defaults to True.

    This option will cause a build error if some members of the class are unmockable or are not methods. In this case, you'll need to define this instance yourself, delegating the mockable methods as follows:

    instance MyClass (MockT m) where
      myMethod x y = mockMethod (MyMethod x y)
      ...
    
  • mockSuffix :: String

    Suffix to add to Action and Matcher names. Defaults to "".

  • mockVerbose :: Bool

    Whether to warn about limitations of the generated mocks. This is mostly useful temporarily for finding out why generated code doesn't match your expectations. Defaults to False.

Instances

Instances details
Default MakeMockableOptions Source # 
Instance details

Defined in Test.HMock.TH

makeMockable :: Q Type -> Q [Dec] Source #

Defines all instances necessary to use HMock with the given type, using default options. The type should be a type class extending Monad, applied to zero or more type arguments.

This defines all of the following instances, if necessary:

makeMockableWithOptions :: Q Type -> MakeMockableOptions -> Q [Dec] Source #

Defines all instances necessary to use HMock with the given type, using the provided options. The type should be a type class extending Monad, applied to zero or more type arguments.

This defines the following instances, if necessary: