GenerateNiceMocks 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
@GenerateNiceMocks
is used.
For example, if @GenerateNiceMocks([MockSpec<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>
.
@GenerateNiceMocks
is different from @GenerateMocks
in two ways:
- only
MockSpec
s are allowed in the argument list - generated mocks won't throw on unstubbed method calls by default, instead some value appropriate for the target type will be returned.
Constructors
-
GenerateNiceMocks(List<
MockSpec> mocks) -
const
Properties
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