Testing Protocol
Version: 1.0.0 Type: Conditional Protocol Stage: IVTR - T (Testing) Max Active: 3 protocols (including base)Trigger Conditions
This protocol activates when the task involves:| Trigger | Keywords | Context |
|---|---|---|
| Test Creation | ”test”, “write tests”, “add tests” | New test development |
| Test Execution | ”run tests”, “execute tests”, “bats” | Test running |
| Coverage | ”coverage”, “test coverage” | Coverage improvement |
| Test Fixes | ”fix test”, “flaky”, “failing test” | Test maintenance |
--protocol testing flag on task creation.
Lifecycle Position: After Validation (V), before Release (R)
Requirements (RFC 2119)
MUST
| Requirement | Description |
|---|---|
| TEST-001 | MUST write tests using BATS framework for Bash |
| TEST-002 | MUST place unit tests in tests/unit/ |
| TEST-003 | MUST place integration tests in tests/integration/ |
| TEST-004 | MUST achieve 100% pass rate before release |
| TEST-005 | MUST test all MUST requirements from specifications |
| TEST-006 | MUST write test summary to manifest |
| TEST-007 | MUST set agent_type: "testing" in manifest |
SHOULD
| Requirement | Description |
|---|---|
| TEST-010 | SHOULD test edge cases and error paths |
| TEST-011 | SHOULD include setup/teardown fixtures |
| TEST-012 | SHOULD use descriptive test names |
| TEST-013 | SHOULD document test rationale |
MAY
| Requirement | Description |
|---|---|
| TEST-020 | MAY add golden tests for output verification |
| TEST-021 | MAY add performance benchmarks |
| TEST-022 | MAY add stress tests for concurrency |
Test Structure
Directory Layout
BATS Test Template
Test Categories
Unit Tests
Test isolated functions without external dependencies.Integration Tests
Test workflows involving multiple components.Golden Tests
Verify output format hasn’t changed unexpectedly.Running Tests
All Tests
Specific Suite
With Coverage
Output Format
Test Summary
Manifest Entry
Integration Points
With Validation Protocol
With Release Protocol
Exit Codes
| Code | Constant | Description |
|---|---|---|
| 0 | SUCCESS | All tests pass |
| 1 | TEST_FAILURE | One or more tests failed |
| 69 | EXIT_TESTS_SKIPPED | Tests were skipped |
| 70 | EXIT_COVERAGE_INSUFFICIENT | Coverage below threshold |
Best Practices
Test Naming
Fixtures
Isolation
Cross-Cutting: Contribution Protocol
When testing involves multi-agent work:- Record tester identity in manifest
- Attribute test authorship via comments
- Track test consensus if multiple testers
protocols/contribution.md for attribution requirements.
References
- Test Framework: BATS
- Existing Tests:
tests/unit/,tests/integration/ - Test Helpers:
tests/test_helper/bats-support/,tests/test_helper/bats-assert/ - Specification:
docs/specs/PROTOCOL-ENFORCEMENT-SPEC.md
