FLUTTER ECOSYSTEM

mockito

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

Latest version
5.6.5
30-day downloads
1.9M
Likes
1.5K
Pub points
160

Package Overview

Selection guidance generated from public package information. For reference only.

Overview

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
Supported platformsAndroidiOSWebmacOSWindowsLinux

Install package

flutter pub add mockito

Categories

Source repository

Related projects