Mockable

A template mixin used to inject code into a class to provide mockable behaviour. Code is nested within the host class to provide access to all host types. Only injects code when using the -unittest compiler switch.

Caveats: Only module level types can be made mockable.

mixin template Mockable (
C
) if (
is(C == class) ||
is(C == interface)
) {}

Members

Classes

Mock
class Mock(C)

Injected by the Mockable mixin template this class contains all mocking behaviour.

Functions

getMock
auto getMock(A args)

Injected by the Mockable mixin template this method allows creation of mock object instances of the mockable class.

Structs

FileLocation
struct FileLocation
MethodCount
struct MethodCount

Examples

1 import dunit.mockable;
2 
3 class T
4 {
5    mixin Mockable!(T);
6 }

Meta