testing

Write and review Flutter and Dart unit, widget, and bloc tests.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill testing-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/testing
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill testing-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flutter and Dart developers often write tests that pass but never catch real regressions, struggle to choose between unit and widget tests, and produce flaky or poorly organized test suites. This Skill provides concrete patterns and rules for writing meaningful tests that actually validate behavior. ## Core Features & Use Cases - Test Validity Checks: Ensures every test can actually fail when real code breaks, avoiding tests that only verify mocks. - Structured Test Patterns: Enforces group-based organization, setUp/tearDown usage, and consistent "should" naming conventions. - Widget & Bloc Testing Guidance: Provides ready-to-use patterns for testWidgets, blocTest, whenListen, and mocktail-based mocking with registerFallbackValue. - Use Case: When adding a new cubit to a Flutter feature, use this Skill to generate a blocTest suite that verifies loading and loaded state transitions driven by a mocked repository. ## Quick Start Write unit and widget tests for my Flutter LoginCubit and LoginView following the testing skill's patterns.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write unit tests for a Flutter cubit or bloc?

Use blocTest from the bloc_test package to verify state transitions. Mock the repository with mocktail, stub its methods in build, call the cubit method in act, and assert the expected sequence of emitted states in expect.

Should I use unit tests or widget tests in Flutter?

Default to unit tests for pure Dart logic, repositories, and cubits using test and bloc_test. Use widget tests with flutter_test and WidgetTester when verifying UI rendering, gesture handling, or widget interaction.

How do I mock dependencies in Dart tests with mocktail?

Create a class extending Mock that implements the repository interface, then stub methods with when and thenAnswer. Call registerFallbackValue in setUpAll for custom types passed to any(), and mock at the repository boundary rather than the HTTP layer.

Why do my Flutter tests pass but not catch real bugs?

Tests that only confirm mocked behavior without exercising real logic cannot catch regressions. Each test should drive a real class under test, such as a cubit, and assert its actual outputs or state transitions rather than the mock's return value.

How should Flutter test files be organized?

Mirror the lib folder structure under the test directory, with one test file per source file named <source_file>_test.dart. Group tests by feature subfolders such as cubit, view, and model, and wrap tests in group blocks named after the class under test.