testing

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

2|Updated Aug 13, 2023
One-click install
npx skills add https://github.com/NNPopov/movie-theater-tickets --skill testing-nnpopov
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/NNPopov/movie-theater-tickets/tree/main/src/clients/.claude/skills/testing
Command: npx skills add https://github.com/NNPopov/movie-theater-tickets --skill testing-nnpopov

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you write, review, and improve Flutter and Dart tests that actually catch regressions instead of merely confirming mocked behavior or trivial library guarantees.

Core Features & Use Cases

  • Test selection guidance: Choose between unit tests and widget tests based on whether you are validating business logic, state transitions, rendering, or user interaction.
  • Quality and flakiness review: Check whether tests are meaningful, focused, stable, and capable of failing when the real code breaks.
  • Flutter test structure: Organize test files with group(), use setUp and tearDown, prefer descriptive "should" names, and mirror the lib/ structure under test/.
  • Mocking best practices: Use mocktail at repository boundaries and verify state changes through real logic rather than mock-only expectations.
  • Use case: A developer adds a new login flow and needs a widget test for the error state plus a unit test for the cubit transitions; this Skill helps design both tests correctly and keep them maintainable.

Quick Start

Use this skill to review my Flutter test file and rewrite it so it follows the recommended structure, assertions, and mocking practices.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I structure Flutter unit and widget tests to validate real behavior?

Separate Flutter tests by using unit tests for business logic and cubit state transitions, and widget tests for rendering or user interaction. Organize files with group(), setUp, and tearDown to maintain clear boundaries between logic validation and UI behavior.

What is the best way to mock repositories in Dart tests using mocktail?

Mock Dart repositories using mocktail at repository boundaries to isolate dependencies. Verify state changes through real logic execution rather than relying solely on mock-only expectations to ensure tests fail when actual code breaks.

Why does my Flutter widget test only confirm mocked behavior instead of catching regressions?

Flutter widget tests often fail to catch regressions when they only assert that mocks were called instead of validating real rendering and state transitions. Require meaningful assertions on actual widget output and user interaction behavior to ensure stability.

Can I use this approach to fix flaky Dart tests and expand test coverage?

Yes, you can fix flaky Dart tests by reviewing them for focus and stability, ensuring they are capable of failing when real code breaks. Expand coverage by adding meaningful unit and widget tests that validate actual behavior across blocs and cubits.

When do I need a unit test versus a widget test for a Flutter login flow?

Use a unit test for a Flutter login flow to validate cubit state transitions and business logic, and use a widget test to validate the error state rendering and user interaction. This separation ensures both logic and UI are correctly covered.