Add tests for the branches the first mutation run left alive.

This commit is contained in:
Robert C. Martin
2026-10-02 10:36:31 -05:00
parent 4909ad241b
commit ce3895211e
5 changed files with 600 additions and 2 deletions
+24
View File
@@ -37,6 +37,16 @@ def test_unscored_rows_sort_after_scored_rows():
assert [row.name for row in rows] == ["worst", "mid", "missing"]
def test_a_low_score_still_sorts_ahead_of_an_unscored_row():
rows = sort_entries(
[
entry(name="plain", crap=1.0, complexity=1),
entry(name="large", crap=None, coverage=None, complexity=8),
]
)
assert [row.name for row in rows] == ["plain", "large"]
def test_unscored_rows_sort_by_complexity():
rows = sort_entries(
[
@@ -67,6 +77,20 @@ def test_edn_uses_crap4clj_keys():
assert text.endswith("}\n")
def test_edn_of_no_entries_is_an_empty_vector():
assert render_edn([]) == "{:entries []}\n"
def test_metrics_directory_can_be_written_twice(tmp_path):
from crapper.metrics import write_metrics
entry_row = entry()
first = write_metrics([entry_row], tmp_path)
second = write_metrics([entry_row], tmp_path)
assert first == second
assert first.is_file()
def test_edn_writes_nil_for_missing_coverage():
text = render_edn([entry(coverage=None, crap=None)])
assert ":coverage nil" in text