dart-add-unit-test

Write and organize unit tests for Dart and Flutter code using package:test.

1|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-add-unit-test-sohampawar1866
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dart-add-unit-test
Source: https://github.com/sohampawar1866/zeromile-go/tree/main/.agents/skills/dart-add-unit-test
Command: npx skills add https://github.com/sohampawar1866/zeromile-go --skill dart-add-unit-test-sohampawar1866

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing consistent, well-structured unit tests in Dart and Flutter projects requires knowing the correct file layout, testing library conventions, and runner commands. This Skill provides a complete workflow for creating regression-free test suites with package:test. ## Core Features & Use Cases - Test File Organization: Mirror the lib directory structure inside test/ with the _test.dart suffix, and place integration tests in integration_test/. - Test Authoring Patterns: Use group(), test(), expect() with matchers, setUp()/tearDown(), and async/await for asynchronous cases. - Mocking with Mockito: Generate mocks via build_runner, configure stubbed responses, and verify interactions for dependency-injected code. - Use Case: After fixing a bug in a Calculator class, generate a grouped test suite with setup, synchronous and asynchronous cases, then run it with dart test to confirm the fix. ## Quick Start Write unit tests for my Dart class in lib/src/calculator.dart using package:test and run them.

Frequently Asked Questions about dart-add-unit-test

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

FAQPage Schema
How do I write unit tests in Dart with package:test?

Import package:test/test.dart, define a main() function, group related cases with group(), and write individual cases with test(). Validate results using expect() with matchers like equals(), isTrue, or throwsA().

How to mock dependencies in Dart tests with Mockito?

Annotate your test with @GenerateNiceMocks, run dart run build_runner build to generate mock classes, then configure stubs with when() and verify calls with verify(). Inject the mock into the class under test via its constructor.

What is the difference between dart test and flutter test?

Use dart test for pure Dart packages and flutter test for Flutter projects, which imports package:flutter_test instead. Both runners ignore the integration_test directory by default, so specify its path explicitly.

Where should Dart test files be placed in a project?

Place test files in the test/ directory at the package root, mirroring the lib/ structure, and append _test.dart to each filename. Integration tests belong in a separate integration_test/ directory at the root.

Why are my Dart integration tests not running?

The default test runners ignore the integration_test directory. Explicitly pass the path, for example dart test integration_test or flutter test integration_test, to execute those suites.