MockSpec<T> class

A specification of how to mock a specific class.

The type argument T is the class-to-mock. If this class is generic, and no explicit type arguments are given, then the mock class is generic. If the class is generic, and T has been specified with type argument(s), the mock class is not generic, and it extends the mocked class using the given type arguments.

The name of the mock class is either specified with the as named argument, or is the name of the class being mocked, prefixed with 'Mock'.

For example, given the generic class, class Foo<T>, then this annotation:

@GenerateMocks([], customMocks: [
    MockSpec<Foo>(),
    MockSpec<Foo<int>>(as: #MockFooOfInt),
])

directs Mockito to generate two mocks: class MockFoo<T> extends Mocks implements Foo<T> and class MockFooOfInt extends Mock implements Foo<int>.

Constructors

MockSpec({Symbol? as, @Deprecated('Avoid adding concrete implementation to mock classes. ' 'Use a manual implementation of the class without `Mock`') List<Type> mixingIn = const [], Set<Symbol> unsupportedMembers = const {}, Map<Symbol, Function> fallbackGenerators = const {}, OnMissingStub? onMissingStub})
Constructs a custom mock specification.
const

Properties

fallbackGenerators Map<Symbol, Function>
final
hashCode int
The hash code for this object.
no setterinherited
mixins List<Type>
final
mockName Symbol?
final
onMissingStub OnMissingStub?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unsupportedMembers Set<Symbol>
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited