Skip to main content
skill CX Codex

testing · evanca — Claude Code skill for Flutter/Dart tests and setup

The testing skill guides Flutter and Dart test writing and review, helps investigate flaky tests, and clarifies when to use unit or widget tests.

MIT ★ 674 updated 2026-10-29

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules
Open on GitHub

What testing does

The skill guides agents through tests for business logic, repositories, widgets, and cubits or blocs. It asks whether a test could catch a regression, rather than merely confirming that a mock returns what it was told to return. A mock-only check does not exercise real logic, so it can miss a broken implementation.

For unit tests, it covers test, bloc_test, and mocktail; for UI checks, it uses flutter_test and WidgetTester. It recommends wrapping widgets in MaterialApp, choosing pump() or pumpAndSettle() for the test’s needs, and using find.byKey when displayed text can vary. Test groups are organized around the class under test, with the test/ tree mirroring lib/.

The mocking guidance uses mocktail and calls for registerFallbackValue() when custom types go through any(). In Claude Code, install the skill from its marketplace or with npx skills.

What it helps with

  • write unit tests for business logic or repositories
  • check widget rendering and interactions
  • spot tests that only confirm mock behavior
  • investigate flaky tests
  • choose between unit and widget tests

Example prompts for the agent

  • Write unit tests for the business logic in this file and make sure they can catch regressions.
  • Review the login screen’s widget test and check that it covers the error message.
  • Investigate the flaky tests and decide which checks belong in unit tests versus widget tests.

How to install testing

1Plugin marketplace

/plugin marketplace add evanca/flutter-ai-rules
/plugin install flutter-ai-skills@flutter-ai-rules

This installs the whole flutter-ai-skills plugin with all its skills

2Skills CLI (Vercel)

npx skills add evanca/flutter-ai-rules --skill testing -a claude-code

3Manually: put the files in place

~/.claude/skills/testing/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/testing/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about testing

How do I install testing in Claude Code?

Add the marketplace with /plugin marketplace add evanca/flutter-ai-rules, then install the skill with /plugin install flutter-ai-skills@flutter-ai-rules.

What does the testing skill do?

It guides Flutter and Dart test writing and review, helps choose test types, and gives advice on flaky tests, mocks, and file organization.

When should I use unit tests versus widget tests?

The skill recommends unit tests for business logic. Use widget tests to check rendering, gestures, or interactions with widgets.

Source text

SKILL.md · MIT
---
name: testing
description: "Use when writing or reviewing Flutter/Dart tests (unit, widget, golden), fixing flaky tests, adding coverage, or choosing between unit and widget tests."
license: MIT
---

# Testing Skill

Write effective, meaningful Flutter and Dart tests that catch real regressions.

## When to Use

Use this skill when:

* Writing unit tests for business logic, repositories, or utility classes.
* Writing widget tests for UI components.
* Reviewing existing tests for correctness and coverage.
* Fixing flaky or false-positive tests.
* Deciding between unit tests, widget tests, and integration tests.

---

## 1. Test Validity

Before writing or accepting a test, ask:

> **"Can this test actually fail if the real code is broken?"**

- Avoid tests that only confirm mocked/fake behavior without exercising real logic.
- Avoid tests that confirm behavior guaranteed by the language or standard library.
- Every test must be capable of catching a real regression.

```dart
// BAD — tests the mock, not real logic
test('should return user', () {
  when(() => repo.getUser()).thenReturn(fakeUser);
  expect(repo.getUser(), fakeUser); // Only proves the mock works
});

// GOOD — tests the cubit's state transitions driven by the mock
blocTest<UserCubit, UserState>(
  'should emit loaded state when getUser succeeds',
  build: () {
    when(() => repo.getUser()).thenAnswer((_) async => fakeUser);
    return UserCubit(repo);
  },
  act: (cubit) => cubit.fetchUser(),
  expect: () => [
    const UserState(status: UserStatus.loading),
    UserState(status: UserStatus.loaded, user: fakeUser),
  ],
);
```

---

## 2. Structure

Always use `group()` in test files. Name the group after the **class under test**:

```dart
group('Counter', () {
  late Counter counter;

  setUp(() {
    counter = Counter();
  });

  test('value should start at 0', () {
    expect(counter.value, 0);
  });

  test('should increment value by 1', () {
    counter.increment();
    expect(counter.value, 1);
  });
});
```

Rules:
- Use `setUp` for shared object creation; use `tearDown` for cleanup (closing streams, controllers).
- Keep each test focused on one behavior.
- Nest `group()` blocks for sub-features when a class has many methods.

---

## 3. Naming

Name test cases using **"should"** to describe expected behavior:

```dart
test('should emit updated list when item is added', () { ... });
test('should throw ArgumentError when input is negative', () { ... });
```

---

## 4. Unit Tests vs Widget Tests

| Type | Target | Tools |
|---|---|---|
| **Unit test** | Pure Dart logic, repositories, cubits/blocs | `test`, `bloc_test`, `mocktail` |
| **Widget test** | Individual widgets, UI behavior, navigation | `flutter_test`, `WidgetTester` |

Default to **unit tests** for business logic. Use **widget tests** when verifying UI rendering, gesture handling, or widget interaction.

---

## 5. Widget Test Patterns

```dart
testWidgets('should display error message on failure', (tester) async {
  await tester.pumpWidget(
    MaterialApp(
      home: BlocProvider<LoginCubit>.value(
        value: mockLoginCubit,
        child: const LoginView(),
      ),
    ),
  );

  // Simulate failure state
  whenListen(
    mockLoginCubit,
    Stream.fromIterable([const LoginState(status: LoginStatus.failure, errorMessage: 'Invalid')]),
    initialState: const LoginState(),
  );
  await tester.pump();

  expect(find.text('Invalid'), findsOneWidget);
});
```

Rules:
- Wrap widgets in `MaterialApp` (or the app's root widget) to provide `MediaQuery`, `Directionality`, etc.
- Use `pump()` for a single frame or `pumpAndSettle()` when animations must complete.
- Prefer `find.byKey` over `find.text` for widgets that may have localized or dynamic text.

---

## 6. Mocking Best Practices

- Use `mocktail` for mocks (no code generation required).
- Call `registerFallbackValue()` in `setUpAll` for custom types passed to `any()`.
- Mock at the repository boundary, not at the HTTP/database layer.

```dart
class MockAuthRepository extends Mock implements AuthRepository {}

void main() {
  setUpAll(() {
    registerFallbackValue(FakeLoginRequest());
  });

  // ... tests
}
```

---

## 7. Test File Organization

```
test/
  feature_a/
    cubit/
      feature_a_cubit_test.dart
    view/
      feature_a_view_test.dart
    model/
      feature_a_model_test.dart
```

- Mirror the `lib/` folder structure under `test/`.
- One test file per source file.
- Name test files `<source_file>_test.dart`.

© Ivanna Kaceviča · MIT · evanca/flutter-ai-rules

Similar skills

All skills for Testing and QA →

testing by other authors comes first.

testing tursodatabase testing is a Claude Code skill for writing SQL and Rust tests, with guidance on choosing .sqltest, TCL, or integration tests and commands to run them. CX Codex +1 1,300installs testing codewithmukesh Lays out a testing strategy for .NET 10 apps: integration tests via WebApplicationFactory, real databases in Testcontainers, Verify snapshots. CX Codex +1 4,000installs testing grafana testing sets up uptime probes, k6 load tests, and frontend observability through Grafana Cloud. Use it before a release or when investigating failures. CX Codex +1 4,600installs testing rshankras testing — a set of TDD workflows and test infrastructure for Apple platform apps. Useful when an agent writes the code and you want tests around it. CX Codex +1 500installs testing Mindrally Defines software testing guidelines for AI agents, covering test isolation, table-driven checks, and mock boundaries. CX Codex +1 888installs flutter alinaqi Skill for Flutter development with Riverpod, Freezed and go_router. Triggers automatically when working with .dart, pubspec.yaml, lib/ and test/. CX Codex +1 746installs dart-add-unit-test dart-lang dart-add-unit-test is a skill for Claude Code, Codex, and other agents that writes and structures package:test unit tests. It activates when adding logic or fixing bugs to prevent regressions. CX Codex +1 21,400installs very-good-ai-flutter-plugin VeryGoodOpenSource The very-good-ai-flutter-plugin plugin for Claude Code provides Flutter and Dart standards for BLoC, GoRouter, tests, and automatic code formatting. ★ 180repo stars flutter-testing Stanislav [MADTeacher] Chernyshev flutter-testing — a skill for writing, fixing and debugging Flutter tests: unit, widget and integration layers, mocks, golden checks. CX Codex +1 1,500installs flutter-testing-skill TestMu AI flutter-testing-skill generates widget tests, integration tests, and golden tests for Flutter in Dart. Runs locally or on real devices via TestMu AI cloud. CX Codex +1 242installs dart-generate-test-mocks dart-lang dart-generate-test-mocks — a Dart testing skill: the agent injects external services through constructors, generates mock classes with mockito and build_runner, then writes the unit test. CX Codex +1 20,300installs

From the same set39

The whole set →
firebase-storage firebase-storage is a skill with guidelines for Firebase Cloud Storage in Flutter apps, covering file uploads, downloads, metadata changes, and storage error handling. CX Codex +1 ★ 674repo stars firebase-data-connect Get guidance for Firebase Data Connect in Flutter, from GraphQL operations and typed SDK generation to access rules and offline handling. CX Codex +1 ★ 674repo stars firebase-remote-config A Flutter skill that keeps the agent on track with Firebase Remote Config: feature flags, in-app defaults, A/B tests and live config updates. CX Codex +1 ★ 674repo stars firebase-cloud-functions Guides your coding agent on calling Firebase Cloud Functions in Flutter with error handling, region configs, and local emulator support. CX Codex +1 ★ 674repo stars firebase-ai This skill gives the agent working patterns for wiring up Firebase AI Logic in a Flutter app and writing Gemini text and chat calls. CX Codex +1 ★ 674repo stars flutterfire-configure Guides Firebase integration in Flutter apps, runs flutterfire configure, and structures multi-flavor project environments. CX Codex +1 ★ 674repo stars flutter-use-column-row-first The flutter-use-column-row-first skill guides Flutter screen layouts with Row, Column, and flexible space. Use it when building a screen that must adapt to different constraints. CX Codex +1 ★ 674repo stars firebase-crashlytics Skill teaches the agent to set up Firebase Crashlytics in Flutter projects: catch fatal and non-fatal errors, log async exceptions, add custom keys, and upload obfuscated build symbols. CX Codex +1 ★ 674repo stars

Project sponsors

Companies that keep this analytics open