AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Testing

skill-evanca-flutter-ai-rules-testing · by evanca

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

No reviews yet
0 installs
15 views
0.0% view→install

Install

$ agentstack add skill-evanca-flutter-ai-rules-testing

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-evanca-flutter-ai-rules-testing)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
11d ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.

How agent discovery & health will work →
Are you the author of Testing? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

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.
// 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(
  '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:

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:

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

testWidgets('should display error message on failure', (tester) async {
  await tester.pumpWidget(
    MaterialApp(
      home: BlocProvider.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.
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 _test.dart.

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.