NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
pub.dev · #247 most downloaded on pub.dev
A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing.
Last release 2 months ago
06 Aug 2026
Release timing varies
gaps range from 2 weeks to 12 months
Nearly every release is documented
notes for 54 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
83 releases · first in 2014
Cast dummy values for extension types to the extension type so they satisfy static type checking in generic return types like Future<ExtensionType> .
Future<ExtensionType>./src/ implementation librariesInvalidMockitoAnnotationException with a clear message when@GenerateMocks customMocks or @GenerateNiceMocks mocks is not a list// ignore: must_be_immutable comment to preventduplicate_ignore warnings.README.md that generated .mocks.dart filenames are based on theexperimental_member_use warnings in generated mock files.void and Future<void>.One column per quarter.
Add support for JS interop extension type mock generation to mockito.
analyzer 14.0.0.Handle JS interop extension types and provide dummy values for them. #4498
* Require analyzer 13.0.0.
analyzer 13.0.0.Allow analyzer 11.0.0 and 12.0.0.
analyzer 11.0.0 and 12.0.0.dart-lang/build monorepo.Allow analyzer: >=8.1.0 <11.0.0.
analyzer: >=8.1.0 <11.0.0.Allow analyzer: >=8.1.0 <10.0.0.
analyzer: >=8.1.0 <10.0.0.Allow source_gen: '>=3.0.0 <5.0.0'.
analyzer: ^8.1.0.source_gen: '>=3.0.0 <5.0.0'.build: '>=3.0.0 <5.0.0'.* Switch to build 3.0.0. * Require Dart SDK ^3.7.0.
build 3.0.0.* Switch to build 3.0.0-dev. * Require Dart SDK ^3.7.0.
build 3.0.0-dev.When formatting a generated mocks library, use the language version of the library with the mockito annotation.
Ignore "must_be_immutable" warning in generated files. Mocks cannot be made immutable anyway, but this way users aren't prevented from using generated
analyzer: '>=6.9.0 <8.0.0'.dart_style: '>=2.3.7 <4.0.0', so that the current Dart language
version can be passed to DartFormatter.source_gen: ">=1.4.0 <3.0.0".pubspec.yaml.Use posix style for local imports.
posix style for local imports.Potentially breaking Changed default String value returned by nice mocks' unstubbed method to include some useful info. This could break the tests tha…
build_extensions build.yaml optionString value returned by nice
mocks' unstubbed method to include some useful info. This could break the
tests that relied on getting an empty String from unstubbed methods.returnNullOnMissingStub and OnMissingStub.returnNull
MockSpec options.Fixed the bug with missing imports for unused type alias arguments.
Deprecate the mixingIn argument to MockSpec. Best practice is to avoid any concrete implementation in classes which extend Mock.
mixingIn argument to MockSpec. Best practice is to avoid
any concrete implementation in classes which extend Mock.sealed/base/final classes.thenReturnInOrder method to mock multiple calls to a single method
in order.provideDummy/provideDummyBuilder functions for users to supply dummy
values to Mockito, to cover cases where codegen can't create one.Fix nice mocks generation in mixed mode (generated code is pre null-safety, while mocked class is null-safe).
@GenerateMocks and @GenerateNiceMocksgenerate_for to test/**. Projects that are generating
mocks for libraries outside of the test/ directory should add an explicit
generate_for argument to include files with mock generating annotations.* Support analyzer 5.0.0.
Fix analyzer and code_builder dependencies.
@GenerateNiceMocks in documentation.unsupportedMembers.required keyword in functions used as default return values.Deprecate the MockSpec returnNullOnMissingStub parameter in favor of the new onMissingStub parameter.
MockSpec parameter, onMissingStub, which allows
specifying three actions to take when a real call is made to a mock method
with no matching stub. The two existing behaviors are the default
behavior of throwing an exception, and the legacy behavior of returning
null. A new behavior is also introduced: returning a legal default value.
With this behavior, legal default values are returned for any given type.MockSpec returnNullOnMissingStub parameter in favor of the
new onMissingStub parameter.@GenerateNiceMocks annotation, that uses the new
"return a legal value" behavior for missing stubs.SmartFake class to be used as a return values for unstubbed
methods. It remembers where it was created and throws a descriptive error
in case the fake is later used.required keyword in function types to match overridden function
types.Fix generation of methods with return type of FutureOr for generic, potentially nullable T.
FutureOr<T> for generic,
potentially nullable T.@GenerateMocks annotations on import and export directives.In creating mocks for a pre-null-safe library, opt out of null safety in the generated code.
toString override method for pre-null safe libraries,
for which the class-to-mock implements toString with additional parameters.MockSpec called
unsupportedMembers. See [NULL_SAFETY_README][] for details.Report when a class cannot be mocked because an inherited method or property accessor requires a private type. #4854
Fix type reference for nested, imported types found in type arguments on a custom class-to-mock. #4508
camel_case_types lint in generated code.Fix an issue generating the correct parameter default value given a constructor which redirects to a constructor declared in a separate library. #4861
Generate Fake classes with unique names. #4689
Implement methods which have been overridden in the mixin hierarchy properly. Previously, mixins were being applied in the wrong order, which could sk
Use an empty list with a correct type argument for a fallback value for a method which returns Iterable. #4853
toString implementations.
#4687toString in a Fake implementation when the class-to-be-faked has
a superclass which overrides toString with additional parameters.
#4640Allow two mocks of the same class (with different type arguments) to be specified with different fallback generators.
inference_failure_on_instance_creation errors in generated code.implementation_imports lint in generated code.Function and Future<Function> return types.Generate a proper mock class when the mocked class overrides toString, hashCode, or operator==. #4672
toString,
hashCode, or operator==.
#4672toString implementation on generated Fakes in order to match the
signature of an overriding method which adds optional parameters.
#4640
Properly type methods in a generated mock class which comes from a "custom
mock" annotation referencing an implicit type. Given a method which references
type variables defined on their enclosing class (for example, T in
class Foo<T>), mockito will now correctly reference T in generated code.
#4674Mock classes now implement a type's nested type arguments properly. #4667
@GenerateMocks annotation's customMocks list can
now specify "fallback generators." These are functions which can be used to
generate fake responses that mockito's code generation needs in order to
return a value for a method with a generic return type. See
NULL_SAFETY_README for details.Migrate Mockito codegen to null safety.
dart:_http).Properly refer to type parameter bounds with import prefixes. #4652
Support the 0.4.x releases of test_api.
test_api.Support 4.x releases of code_builder.
Allow calling methods with void return types w/o stubbing. #4638
Support 1.x releases of source_gen.
Support the latest build packages and dart_style.
Fix mock generation of type which has a supertype which mixes in a mixin.
Breaking change: Remove the public constructor for VerificationResult.
verifyInOrder now returns a List<VerificationResult> which stores
arguments which were captured in a call to verifiyInOrder.VerificationResult.verify been used inside the verifyInOrder.Fix generation of duplicate mock getters and setters from inherited classes.
Breaking change: Change the error which is thrown if a method is called and no method stub was found, from NoSuchMethodError to MissingStubError.
Mock.noSuchMethod's optional positional parameter,
"returnValue" is changed to a named parameter, and a second named parameter is
added. Any manual mocks which call Mock.noSuchMethod with a second
positional argument will need to instead use the named parameter.void (like setters) or
Future<void>, even if unstubbed.Fix noSuchMethod invocation of setters in generated mocks.
noSuchMethod invocation of setters in generated mocks.Annotate overridden getters and setters with @override.
@override.Improve static analysis of generated code.
Fix issue with generated code which references a class declared in a part (#4604).
Fix an issue with generated mocks overriding methods from Object, such as operator == (#4603).
operator == (#4603).Remove deprecated typed, typedArgThat, and typedCaptureThat APIs.
lib/src/builder.dart opts out of null safety.http back to dev_dependencies. It's used by the example.typed, typedArgThat, and typedCaptureThat APIs.Nothing published for this version
Bug fix: fix race condition when a new daemon immediately starts after shutdown.
.dart_tool in the workspace by default.daemonSharedPath to keep support for otherthrowOnMissingStub accepts an optional argument, exceptionBuilder, which
will be called to build and throw a custom exception when a missing stub is
called.Introduce experimental code-generated mocks. This is primarily to support the new "Non-nullable by default" (NNBD) type system coming soon to Dart.
Mock.noSuchMethod. This may break
clients who use the Mock class in unconventional ways, such as overriding
noSuchMethod on a class which extends Mock. To fix, or prepare such code,
add a second parameter to such overriding noSuchMethod declaration.2.7.0.Mark the unexported and accidentally public setDefaultResponse as deprecated.
setDefaultResponse as
deprecated.named function as deprecated.when) or verification (verify and untilCalled).Nothing published for this version
Add a Fake class for implementing a subset of a class API as overrides without misusing the Mock class.
Fake class for implementing a subset of a class API as overrides
without misusing the Mock class.Replace the dependency on the _test_ package with a dependency on the new _test_api_ package. This dramatically reduces mockito's transitive dependenc
Rollback the _test_api_ part of the 3.0.1 release. This was breaking tests that use Flutter's current test tools, and will instead be released as part
Replace the dependency on the _test_ package with a dependency on the new _test_api_ package. This dramatically reduces mockito's transitive dependenc
Deprecate the typed API; instead of wrapping other Mockito API calls, like any, argThat, captureAny, and captureArgThat, with a call to typed, the reg…
Deprecate the typed API; instead of wrapping other Mockito API calls, like
any, argThat, captureAny, and captureArgThat, with a call to typed,
the regular API calls are to be used by themselves. Passing any and
captureAny as named arguments must be replaced with anyNamed() and
captureAnyNamed, respectively. Passing argThat and captureThat as named
arguments must include the named parameter.
Introduce a backward-and-forward compatible API to help users migrate to Mockito 3. See more details in the upgrading-to-mockito-3 doc.
thenReturn now throws an ArgumentError if either a Future or Stream
is provided. thenReturn calls with futures and streams should be changed to
thenAnswer. See the README for more information.
Support stubbing of void methods in Dart 2.
thenReturn and thenAnswer now support generics and infer the correct
types from the when call.
Completely remove the mirrors implementation of Mockito (mirrors.dart).
Fix compatibility with new noSuchMethod Forwarding feature of Dart 2. This is thankfully a mostly backwards-compatible change. This means that this version of Mockito should continue to work:
>=2.0.0-dev.16.0,dart --preview-dart-2, or with
Flutter Beta 3), andThis change, when combined with noSuchMethod Forwarding, will break a few code paths which do not seem to be frequently used. Two examples:
class A {
int fn(int a, [int b]) => 7;
}
class MockA extends Mock implements A {}
var a = new MockA();
when(a.fn(typed(any), typed(any))).thenReturn(0);
print(a.fn(1));
This used to print null, because only one argument was passed, which did
not match the two-argument stub. Now it will print 0, as the real call
contains a value for both the required argument, and the optional argument.
a.fn(1);
a.fn(2, 3);
print(verify(a.fn(typed(captureAny), typed(captureAny))).captured);
This used to print [2, 3], because only the second call matched the verify
call. Now, it will print [1, null, 2, 3], as both real calls contain a value
for both the required argument, and the optional argument.
Upgrade package dependencies.
Throw an exception when attempting to stub a method on a Mock object that already exists.
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →