GenerateMocks class
An annotation to direct Mockito to generate mock classes.
During code generation, Mockito will generate a
Mock{Type} extends Mock
class for each class to be mocked, in
{name}.mocks.dart
, where {name}
is the basename of the file in which
@GenerateMocks
is used.
For example, if @GenerateMocks([Foo])
is found at the top-level of a Dart
library, foo_test.dart
, then Mockito will generate
class MockFoo extends Mock implements Foo
in a new library,
foo_test.mocks.dart
.
If the class-to-mock is generic, then the mock will be identically generic.
For example, given the class class Foo<T, U>
, Mockito will generate
class MockFoo<T, U> extends Mock implements Foo<T, U>
.
Custom mocks can be generated with the customMocks:
named argument. Each
mock is specified with a MockSpec object.
Constructors
-
GenerateMocks(List<
Type> classes, {List<MockSpec> customMocks = const []}) -
const
Properties
-
classes
→ List<
Type> -
final
-
customMocks
→ List<
MockSpec> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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