dart-testing
Installation
SKILL.md
Dart Testing Suite
Contents
Unit Testing
Utilize package:test as the standard testing library for Dart CLI and backend applications.
- Organize test files to mirror the
libdirectory structure. Append_test.dartto test files. - Group related tests using the
group()function. - Use
setUp()andtearDown()for shared test state. - Write pure logic inside Domain/BLoC and extract to static pure functions for 100% unit test coverage.
- Use string interpolation for test group names:
group('$ClassName', ...) - Structure each test using the Arrange-Act-Assert (Given-When-Then) convention:
- Arrange: Set up mocks, create instances, prepare input data.
- Act: Call the method under test.
- Assert: Verify the output or side effects.
- Separate setup from verification to keep tests readable and maintainable.