From 8801820fe8bc955e633dbdc617e1d740df4a306b Mon Sep 17 00:00:00 2001 From: swapnil <78632212+swapnilpaliwal-sd@users.noreply.github.com> Date: Mon, 28 Sep 2026 09:52:44 -0700 Subject: [PATCH] impact: a test that only stubs the change is not a test row to run The tests line now also names callables in test code that the count does not credit. A test that only stubs the change on a mock, or reaches it only through a type it holds as a mock, is listed apart as [stubs it] and is not one of them; without this it was told both "not counted" and "treat as a test to run". Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com> --- .../axiomcode/skills/axiomcode/scripts/axiomcode-impact | 5 ++++- .../cases/csharp/mock-stub-is-not-a-test-route/case.json | 9 ++++++++- tests/cases/java/mock-stub-is-not-a-test-route/case.json | 6 +++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/plugins/axiomcode/skills/axiomcode/scripts/axiomcode-impact b/plugins/axiomcode/skills/axiomcode/scripts/axiomcode-impact index 1a3acbe37..b43006537 100755 --- a/plugins/axiomcode/skills/axiomcode/scripts/axiomcode-impact +++ b/plugins/axiomcode/skills/axiomcode/scripts/axiomcode-impact @@ -2297,7 +2297,10 @@ def main(argv): # (a [test] entry point, a test row) but that the count does not credit -- a runner entry this tool does not # collect (a custom test attribute, a script's main), a remote hop the test walk does not take -- made "tests: 0" # sit under a [test] row. They are named here, and `next:` counts them as tests to run. - test_rows = sorted(({m for m, _ in ent if _is_t(m)} | {c for c, role, why, cert, loc, n in D if _is_t(c) and cert != 'alongside'}) - set(tests), + # A test that only stubs it on a mock, or reaches it only through a type it holds as one, is not one of them: it is + # the [stubs it] line below, which says it is not counted because a body change cannot fail it. + test_rows = sorted(({m for m, _ in ent if _is_t(m)} | {c for c, role, why, cert, loc, n in D if _is_t(c) and cert not in ('alongside', 'stubs it') + and not why.startswith('stubs a method of this name')}) - set(tests) - set(stubbed), key=lambda m: (g.disp(m), g.loc(m))) if test_rows: print(f" {'and ' if tests else 'but '}{len(test_rows)} callable(s) in test code listed above reach it by a route this count does not credit " diff --git a/tests/cases/csharp/mock-stub-is-not-a-test-route/case.json b/tests/cases/csharp/mock-stub-is-not-a-test-route/case.json index 127aef5bc..05ccdb04b 100644 --- a/tests/cases/csharp/mock-stub-is-not-a-test-route/case.json +++ b/tests/cases/csharp/mock-stub-is-not-a-test-route/case.json @@ -20,7 +20,8 @@ "[fixture]", "MoqStubTests::", "[by name] 1 test", - "[by name] 2 test" + "[by name] 2 test", + "callable(s) in test code listed above reach it" ] }, { @@ -32,6 +33,9 @@ ], "want": [ "SnapshotTests::VerifiesASnapshot" + ], + "avoid": [ + "callable(s) in test code listed above reach it" ] }, { @@ -55,6 +59,9 @@ "want": [ "only stub it on a mock", "[resolved] Checkout.Total" + ], + "avoid": [ + "callable(s) in test code listed above reach it" ] } ] diff --git a/tests/cases/java/mock-stub-is-not-a-test-route/case.json b/tests/cases/java/mock-stub-is-not-a-test-route/case.json index c5f7fecb2..a5678ad4f 100644 --- a/tests/cases/java/mock-stub-is-not-a-test-route/case.json +++ b/tests/cases/java/mock-stub-is-not-a-test-route/case.json @@ -22,7 +22,8 @@ "avoid": [ "[sound] 3", "[sound] 4", - "[fixture]" + "[fixture]", + "callable(s) in test code listed above reach it" ] }, { @@ -47,6 +48,9 @@ "want": [ "only stub it on a mock", "[resolved] Checkout.total" + ], + "avoid": [ + "callable(s) in test code listed above reach it" ] }, {