Search categories, packages and repositories

Package detailsv5.8.1

mockito

A mock framework inspired by Mockito with APIs for Fakes, Mocks, behavior verification, and stubbing.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
2.8M
Likes
1.5K
Pub points
140

Install package

flutter pub add mockito

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Mockito is a testing framework for Dart and Flutter that enables developers to create mocks, fakes, and stubs for dependencies. It supports behavior verification and method stubbing, making it easier to isolate units of code during testing. Inspired by the popular Mockito library in other languages, it integrates seamlessly with Dart's testing ecosystem. The package is ideal for unit and integration tests where real implementations are impractical or undesirable. It works across all major platforms supported by Flutter.

Use cases

  • Unit testing with dependency injection
  • Integration testing with mocked services
  • Testing asynchronous operations
  • Verifying method calls and interactions
  • Simulating API responses
  • Testing business logic without external dependencies

Key features

  • Support for mocks and fakes
  • Method stubbing and return values
  • Behavior verification
  • Easy setup with annotations
  • Comprehensive test isolation
  • Cross-platform compatibility

Suitable for

  • Developers writing unit tests
  • Teams practicing test-driven development
  • Projects requiring clean separation of concerns
  • Flutter apps with complex dependencies
  • Test automation engineers

Considerations

  • Requires knowledge of mocking concepts
  • May increase test complexity if overused
  • Needs proper setup with build_runner
  • Not suitable for end-to-end testing
  • Can lead to brittle tests if not managed carefully

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Questions? Suggestions? Found a bug? Please file an issue or start a discussion.

Code generation for Flutter and Dart packages.

See the build_runner package documentation for how to use build_runner builders in your package to add serialization, data classes, data binding, dependency injection, mocking and more.

See the build package documentation to create your own builder.

This repo also hosts the following builders and packages for use by builders.

Categories

Dependencies

Dependency list 10 items

Source repository

Projects using this package