dart-testing

Generates and diagnoses Dart and Flutter tests using test, flutter_test, mockito, and bloc_test.

Updated Jul 6, 2026
One-click install
npx skills add https://github.com/chenziyang110/launchdeck --skill dart-testing-chenziyang110
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-testing
Source: https://github.com/chenziyang110/launchdeck/tree/main/.claude/skills/dart-testing
Command: npx skills add https://github.com/chenziyang110/launchdeck --skill dart-testing-chenziyang110

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing reliable Dart and Flutter tests requires choosing the right framework, mocking strategy, and test tier for each scenario, and mistakes lead to flaky or meaningless tests. This Skill provides a structured workflow for designing, generating, and debugging unit, widget, BLoC, and integration tests. ## Core Features & Use Cases - Phased Test Generation: Follows a five-phase protocol covering context analysis, strategy selection, test case design, code generation, and verification. - Framework-Specific Patterns: Includes ready-to-use examples for unit tests, widget tests with flutter_test, mockito and mocktail mocking, bloc_test state testing, and integration tests. - Flaky Test Guardrails: Enforces best practices like pumpAndSettle, FakeAsync, and MockClient to eliminate non-deterministic failures. - Use Case: When asked to add tests for a Flutter login screen, the Skill inspects the widget tree, generates testWidgets cases with find.byKey discovery, and provides the exact flutter test commands to run and measure coverage. ## Quick Start Ask the agent to write widget tests for your Flutter login screen using flutter_test and mockito, then run flutter test --coverage to verify.

Frequently Asked Questions about dart-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write widget tests in Flutter?▼

Use testWidgets from flutter_test with tester.pumpWidget to render the widget, then locate elements with find.byKey or find.text and assert with matchers like findsOneWidget. Call tester.pumpAndSettle to wait for animations before making assertions.

How to mock dependencies in Dart tests with mockito?▼

Annotate the test file with @GenerateMocks listing the classes to mock, then run dart run build_runner build to generate the mocks file. Use verify to check method calls and when to stub return values; mocktail is an alternative that needs no code generation.

What is the difference between mockito and mocktail in Dart?▼

Mockito uses build_runner code generation driven by @GenerateMocks annotations, while mocktail works without any code generation step. Both mock at boundary interfaces like repositories and HTTP clients; mocktail is simpler for projects avoiding build_runner.

How do I test BLoC state changes in Flutter?▼

Use blocTest from the bloc_test package with build to create the bloc, act to dispatch events, and expect to assert the emitted state sequence. This verifies state transitions without rendering any widgets.

Why are my Flutter widget tests flaky?▼

Flakiness usually comes from using Future.delayed or arbitrary pump durations for synchronization, real network calls, or shared singleton state. Fix it by using tester.pumpAndSettle, FakeAsync for timers, MockClient for HTTP, and resetting state in setUp.

How do I measure Flutter test coverage?▼

Run flutter test --coverage to generate coverage/lcov.info, then use genhtml to produce an HTML report. The very_good_cli tool can enforce a minimum threshold with very_good test --coverage --min-coverage 80.