Mock library for Dart, inspired by Java's Mockito
open sourceApache-2.0free
mockito is the Dart team's mock library for Dart and Flutter tests, inspired by Java's Mockito. With null safety it generates mock classes with build_runner from @GenerateNiceMocks annotations, then stubs methods, verifies calls and captures arguments; it also has APIs for fakes.
Problems it solves
- mock a dependency in my Dart unit tests
- verify that my Flutter code called a method with the right arguments
- stub a repository class in Dart tests without writing a fake by hand
Features
- generated mock classes with build_runner
- stubbing and behaviour verification
- argument matchers and captors
- fakes for classes you don't want to mock
Alternatives
The same job
These do what mockito does.
- mocktail Mocks for Dart and Flutter tests without code generation
