dart-generate-test-mocks

Installation
SKILL.md

Contents

Structuring Code for Testability

To write effective unit tests, structure your codebase using dependency injection. Isolate operations that interact with physical layers (like disk storage, external servers, and platform channels) so they can be replaced by mock objects at test time:

  • Constructor Injection: Pass all service dependencies (e.g. HTTP clients, database helper clients) into class constructors rather than instantiating them directly within the class.
  • Interface Segregation: Define clear, abstract base classes representing your service contracts. Mocks should ideally target these abstract contracts rather than concrete service implementations.

Managing Dev Dependencies

Configure your pubspec.yaml to specify the packages required for code generation and mock testing:

Installs
10
GitHub Stars
21
First Seen
May 28, 2026
dart-generate-test-mocks — dhruvanbhalara/skills