Skip to content

test: cover AddVBFile, AddGlobalJson and SetRuntimeSdk guards - #262

Merged
samtrion merged 1 commit into
mainfrom
test/stryker-guard-clause-gaps-vbfile-globaljson
Nov 4, 2026
Merged

samtrion merged 1 commit into
mainfrom
test/stryker-guard-clause-gaps-vbfile-globaljson

Conversation

@samtrion

@samtrion samtrion commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The latest mutation run on main reports about 11 survivors on guard clauses that are not part of the failing-test cluster (per the report; the log only carries totals: 51 survived, 40 of them only covered by failing tests). Affected spots:

  • ProjectBuilderExtensions.AddVBFile: ThrowIfNullOrWhiteSpace(fileName) and (content)
  • ProjectFactoryExtensions.AddGlobalJson: ThrowIfNullOrWhiteSpace(runtimeVersion) and configure?.Invoke(builder)
  • GlobalJsonBuilder.SetRuntimeSdk whitespace guard and CreateAsync ThrowIfCancellationRequested
  • Duplicate-file message strings in SubdirectoryBuilder.CreateFile and TemporaryDirectoryBuilder.CreateFile (message mutated to empty)

Root cause

Empty-name and empty-content tests exist only for AddCSharpFile. AddGlobalJson has no unit test (only integration tests, which fail in the CI container). The duplicate-file tests assert only the exception type, not the message.

Change

Test-only. New unit tests:

  • AddVBFile with empty/whitespace file name and content
  • AddGlobalJson with empty/whitespace runtime version, and the configure callback (invoked once, receives a GlobalJsonBuilder) in a new ProjectFactoryExtensionsTests
  • SetRuntimeSdk with empty/whitespace
  • GlobalJsonBuilder.CreateAsync with a pre-cancelled token (may turn out equivalent for mutation purposes)
  • Duplicate-file tests now assert the message contains the file name and "already exists"

Unit suite passes locally (378 tests, net10.0).

Before / After

Run: https://github.com/dailydevops/projectbuilders/actions/runs/40810654395 (mutation.yml dispatched on this branch) vs. the latest main run.

metric before after
mutation score 74.73 % 76.23 %
killed 349 356
survived 51 44
survived (only covered by failing tests) 40 40
compile errors / no coverage / ignored 27 / 27 / 109 27 / 27 / 109
failing tests in initial run 16 / 14 / 30 16 / 14 / 30
runtime 9 min 13.5 min (runner variance, test count increased only slightly)

Seven mutants were killed, at the low end of the approximately 8 to 11 estimate. The remaining survivors outside the failing-test cluster are not itemised in the log, so which ones remain is not verified.

Risk / what this does not change

No production code change. The failing-test cluster (integration tests failing in the container) is untouched and still limits the achievable score.

Mutation testing reports survivors on guard clauses that no unit test
exercises: AddVBFile (empty/whitespace file name and content),
ProjectFactoryExtensions.AddGlobalJson (runtimeVersion guard and the
configure callback), GlobalJsonBuilder.SetRuntimeSdk (whitespace guard)
and CreateAsync (cancellation check). The duplicate-file tests for
SubdirectoryBuilder and TemporaryDirectoryBuilder only asserted the
exception type, so the message mutants survived as well.

Add the missing unit tests and assert the duplicate-file message.
No production code is changed.
@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.69%. Comparing base (3375b9a) to head (46fe69c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #262   +/-   ##
=======================================
  Coverage   89.69%   89.69%           
=======================================
  Files          31       31           
  Lines         728      728           
  Branches       85       85           
=======================================
  Hits          653      653           
  Misses         67       67           
  Partials        8        8           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samtrion
samtrion merged commit 4b57235 into main Nov 4, 2026
16 checks passed
@samtrion
samtrion deleted the test/stryker-guard-clause-gaps-vbfile-globaljson branch November 4, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant