testing

Featured

Use when writing or reviewing Flutter/Dart tests (unit, widget, golden), fixing flaky tests, adding coverage, or choosing between unit and widget tests.

Testing & QA 637 stars 66 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
93
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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 t...

Details

Author
evanca
Repository
evanca/flutter-ai-rules
Created
1 years ago
Last Updated
1 weeks ago
Language
Shell
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category