|
| 1 | +"""Tests for TDD enforcement language in implementation-plan/SKILL.md. |
| 2 | +
|
| 3 | +TDD spec for task dso-awsv (GREEN task): |
| 4 | +- SKILL.md Step 3 must contain explicit TDD enforcement rules covering: |
| 5 | + 1. 'no conditional logic' — ban on conditional/parametric logic in tests |
| 6 | + 2. 'change-detector test' — escape hatch terminology |
| 7 | + 3. 'infrastructure-boundary-only' — scope qualifier for escape hatch |
| 8 | + 4. 'RED test task' — required naming for the failing-test task |
| 9 | + 5. 'behavioral content' — definition distinguishing real tests from test stubs |
| 10 | + 6. Integration test task rule language |
| 11 | + 7. 'existing coverage' — prohibition on relying on pre-existing tests |
| 12 | + 8. 'no test environment' — prohibition on writing tests needing special env |
| 13 | + 9. Justification requirement for escape hatch use |
| 14 | +
|
| 15 | +All tests are marked xfail(strict=True) because SKILL.md has not yet been |
| 16 | +updated by dso-awsv. They will turn GREEN once dso-awsv lands its changes. |
| 17 | +""" |
| 18 | + |
| 19 | +import pathlib |
| 20 | + |
| 21 | +import pytest |
| 22 | + |
| 23 | +REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] |
| 24 | +SKILL_MD = REPO_ROOT / "plugins" / "dso" / "skills" / "implementation-plan" / "SKILL.md" |
| 25 | + |
| 26 | + |
| 27 | +def _read_skill() -> str: |
| 28 | + return SKILL_MD.read_text() |
| 29 | + |
| 30 | + |
| 31 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 32 | +def test_skill_md_contains_no_conditional_logic() -> None: |
| 33 | + """SKILL.md must prohibit conditional/parametric logic in TDD test tasks.""" |
| 34 | + content = _read_skill() |
| 35 | + assert "no conditional logic" in content, ( |
| 36 | + "SKILL.md Step 3 must contain 'no conditional logic' to prohibit " |
| 37 | + "parametric test stubs that always pass." |
| 38 | + ) |
| 39 | + |
| 40 | + |
| 41 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 42 | +def test_skill_md_contains_change_detector_test() -> None: |
| 43 | + """SKILL.md must name the escape hatch anti-pattern as 'change-detector test'.""" |
| 44 | + content = _read_skill() |
| 45 | + assert "change-detector test" in content, ( |
| 46 | + "SKILL.md Step 3 must reference 'change-detector test' as the " |
| 47 | + "canonical name for the escape hatch anti-pattern." |
| 48 | + ) |
| 49 | + |
| 50 | + |
| 51 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 52 | +def test_skill_md_contains_infrastructure_boundary_only() -> None: |
| 53 | + """SKILL.md must restrict escape hatch to infrastructure-boundary-only cases.""" |
| 54 | + content = _read_skill() |
| 55 | + assert "infrastructure-boundary-only" in content, ( |
| 56 | + "SKILL.md Step 3 must contain 'infrastructure-boundary-only' to scope " |
| 57 | + "when the change-detector test escape hatch is permitted." |
| 58 | + ) |
| 59 | + |
| 60 | + |
| 61 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 62 | +def test_skill_md_contains_red_test_task() -> None: |
| 63 | + """SKILL.md must require a named 'RED test task' as a distinct task in the plan.""" |
| 64 | + content = _read_skill() |
| 65 | + assert "RED test task" in content, ( |
| 66 | + "SKILL.md Step 3 must require a 'RED test task' as a standalone task " |
| 67 | + "that writes the failing test before implementation." |
| 68 | + ) |
| 69 | + |
| 70 | + |
| 71 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 72 | +def test_skill_md_contains_behavioral_content() -> None: |
| 73 | + """SKILL.md must define 'behavioral content' to distinguish real tests.""" |
| 74 | + content = _read_skill() |
| 75 | + assert "behavioral content" in content, ( |
| 76 | + "SKILL.md Step 3 must use 'behavioral content' to distinguish tests " |
| 77 | + "with real assertions from empty stubs or pass-through fixtures." |
| 78 | + ) |
| 79 | + |
| 80 | + |
| 81 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 82 | +def test_skill_md_contains_integration_test_task_rule() -> None: |
| 83 | + """SKILL.md must include rule language governing integration test tasks.""" |
| 84 | + content = _read_skill() |
| 85 | + assert "integration test task" in content, ( |
| 86 | + "SKILL.md Step 3 must contain 'integration test task' rule language " |
| 87 | + "specifying how integration tests fit into the TDD task structure." |
| 88 | + ) |
| 89 | + |
| 90 | + |
| 91 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 92 | +def test_skill_md_contains_existing_coverage() -> None: |
| 93 | + """SKILL.md must prohibit relying on existing coverage to satisfy RED.""" |
| 94 | + content = _read_skill() |
| 95 | + assert "existing coverage" in content, ( |
| 96 | + "SKILL.md Step 3 must reference 'existing coverage' to clarify that " |
| 97 | + "pre-existing passing tests do not satisfy the RED requirement." |
| 98 | + ) |
| 99 | + |
| 100 | + |
| 101 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 102 | +def test_skill_md_contains_no_test_environment() -> None: |
| 103 | + """SKILL.md must prohibit tests that require a special test environment.""" |
| 104 | + content = _read_skill() |
| 105 | + assert "no test environment" in content, ( |
| 106 | + "SKILL.md Step 3 must contain 'no test environment' to prohibit " |
| 107 | + "writing tests that require special setup unavailable in CI." |
| 108 | + ) |
| 109 | + |
| 110 | + |
| 111 | +@pytest.mark.xfail(strict=True, reason="RED: SKILL.md not yet updated by dso-awsv") |
| 112 | +def test_skill_md_contains_justification_requirement() -> None: |
| 113 | + """SKILL.md must require a written justification when invoking the escape hatch.""" |
| 114 | + content = _read_skill() |
| 115 | + assert "justification requirement" in content, ( |
| 116 | + "SKILL.md Step 3 must contain 'justification requirement' to require " |
| 117 | + "agents to document why the change-detector test escape hatch was invoked." |
| 118 | + ) |
0 commit comments