skills/dart/dart-testing/SKILL.md
Write unit tests with mocking and coverage analysis for pure Dart projects and CLI apps. Use when testing business logic, generating mocks with Mockito or mocktail, or measuring test coverage.
npx skillsauth add dhruvanbhalara/skills dart-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Utilize package:test as the standard testing library for Dart CLI and backend applications.
lib directory structure. Append _test.dart to test files.group() function.setUp() and tearDown() for shared test state.group('$ClassName', ...)Use package:mockito or package:mocktail for dependency mocking.
@GenerateNiceMocks([MockSpec<YourService>()]) with Mockito, and run build_runner.verify(mockObj.method()).called(1).dart test --coverage=coverage or flutter test --coverage.format_coverage to convert the lcov.info into an HTML report if needed.Follow this sequential workflow when testing a Dart feature. Copy the checklist to track progress.
_test.dart.dart run build_runner build to generate mocks if using Mockito.dart test.dart test --coverage=coverage and verify coverage targets are met.development
Perform REST API networking operations (GET, POST, PUT, DELETE) using the lightweight and robust standard `http` package, including platform configurations and background parsing models.
development
Configure internationalization and localization support using Flutter's built-in l10n system, App Resource Bundle (ARB) files, and ICU formatting syntax.
development
Create model classes with fromJson/toJson using dart:convert and Dart 3 pattern matching. Use when manually mapping JSON to classes, parsing HTTP responses, or choosing between manual and code-generated serialization.
data-ai
Diagnose and fix Flutter layout constraint violations (RenderFlex overflow, unbounded height/width, ParentData misuse). Use when encountering layout exceptions, yellow-black overflow stripes, or red error screens.