testing

Write Dart unit tests, Flutter widget tests, and golden file tests following VGV conventions.

162|23|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin --skill testing-verygoodopensource
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin/tree/main/skills/testing
Command: npx skills add https://github.com/VeryGoodOpenSource/vgv-ai-flutter-plugin --skill testing-verygoodopensource

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing consistent, maintainable tests in Dart and Flutter projects requires many conventions — naming, group structure, mocking, isolation, golden tagging — that are easy to get wrong or apply inconsistently across a team. This Skill encodes Very Good Ventures testing standards so every unit, widget, and golden test follows the same production-grade patterns. ## Core Features & Use Cases - Unit & Widget Test Standards: Enforces hierarchical group/test naming that reads as natural sentences, private mocktail mocks, late + setUp lifecycle patterns, and the shared pumpApp helper instead of inline MaterialApp boilerplate. - Golden File Testing: Covers TestTag.golden tagging, matchesGoldenFile usage, and running or updating goldens via the very_good_cli MCP test tool with tags, coverage, and timeout parameters. - Anti-Pattern Detection: Applies equally when a request asks for forbidden patterns — package:mockito, raw string tags, shared mutable state between tests, or asserting padding/color in widget tests — and corrects them. - Use Case: Ask for a golden test for an AppButton widget, and get a properly tagged testWidgets using pumpApp, matchesGoldenFile, and the correct MCP tool invocation to generate the reference image. ## Quick Start Write a golden test for my AppButton widget using the testing conventions.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I write a golden test in Flutter?

Create a testWidgets that pumps the widget via a shared pumpApp helper, then call expectLater with matchesGoldenFile pointing to a goldens/ PNG path. Tag the file or test with a TestTag.golden constant so goldens can run or update independently.

Should I use mocktail or mockito for Dart mocking?

Use package:mocktail, never package:mockito. Declare mocks as private classes like _MockApiClient extends Mock, stub with when/thenAnswer, verify with verify(...).called(n), and register fallback values in setUpAll for custom types used with any().

How do I structure Flutter widget tests with bloc_test?

Use MockBloc or MockCubit from package:bloc_test instead of real blocs, stub the state in setUp, and wrap the widget in BlocProvider.value inside a buildSubject helper. Group tests by behavior categories like renders, navigates, and calls.

Why does pumpAndSettle hang in my Flutter test?

pumpAndSettle hangs when infinite animations like CircularProgressIndicator are present, since frames never settle. Use pump() with explicit durations instead, and pass timeout_seconds to the test tool so a hung run is killed.

How do I run only golden tests or update goldens?

Run them through the very_good_cli MCP test tool: pass tags: 'golden' to run only goldens, add update_goldens: true to regenerate reference PNGs, or exclude_tags: 'golden' to skip them. Commit the updated PNG files alongside the tests.

When should I use golden tests versus widget tests?

Use widget tests for behavioral outcomes like text content, callbacks, and navigation. Use golden tests for visual appearance such as layout, colors, and typography. Never assert padding, color, or font size in a widget test.