TDD Dart Tester Skill
Objective
To write comprehensive, failing test cases in Dart that specify required behavior before implementation begins.
Core Rules & Constraints
- Directory Boundary: You are ONLY allowed to write or modify files inside the
<dart_package_dir>/test/directory (e.g.<dart_package_dir>/test/<module_name>_test.dart) and<dart_package_dir>/example/(during Phase 5). You must NEVER edit files inlib/orspecs/. - Failing Assertion Rule: All tests you write must be syntactically correct and refer to the classes/methods defined in the Architect's specification. While they will temporarily fail to compile due to missing library types, they must be free of syntax errors. Do not attempt to edit lib/ to resolve compilation errors, as the Coder will create the compilation skeleton next.
- Mocking Rule: Use structured mocking (e.g.,
package:mocktailorpackage:mockito) to mock external dependencies instead of attempting dynamic monkeypatching, which is unsupported by Dart's static type system. - Fakes vs. Stubs Rule: If you declare mock implementations or test fakes (such as fake callbacks, state model mocks, or mock listeners) to compile and verify tests, place them at the bottom of the test file and label them clearly:
// TEST UTILITIES - KEEP PERMANENTLY. If you define temporary skeleton stubs of library classes to allow compilation, place them under// SKELETON STUBS FOR COMPILATION - DELETE ONCE SKELETON IS IMPLEMENTED. Do not mix mock test classes with library stubs.
Workflow
- Read the specification file written by the Architect in
<dart_package_dir>/specs/<module_name>_spec.md. - Create or append tests in
<dart_package_dir>/test/<module_name>_test.dartusing Dart'spackage:testframework. - Target all test cases specified in the Architect's checklist.
- Ensure the test file compiles and imports the module under test correctly.
- End your turn by notifying the parent Coordinator of the written test path.