Skip to content

test: cover operator null guards and dangling operator descriptions - #613

Merged
samtrion merged 2 commits into
mainfrom
fix/stryker-operator-guard-and-description-tests
Oct 29, 2026
Merged

samtrion merged 2 commits into
mainfrom
fix/stryker-operator-guard-and-description-tests

Conversation

@samtrion

@samtrion samtrion commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Mutation run 40488160594 reports MeasurementScopeExtensions.cs with 1 NoCoverage mutant (block removal of return NullScope.Instance;) and 2 surviving statement mutants (ArgumentNullException.ThrowIfNull(logger) and ArgumentException.ThrowIfNullOrWhiteSpace(identifier) in StartMeasurement). Log: 1 mutants got status NoCoverage, Killed: 16, Survived: 3, final mutation score is 80.00 %. No existing test passes LogLevel.None. (The HTML report is not part of the logs; the third survivor is assumed to be the Stopwatch.Stop one from the arithmetic, not verified.)

Root cause

The completionLevel is LogLevel.None branch is never executed. The two guards are only observable on that branch, since MeasurementScope's constructor repeats the same checks (same parameter names) for all other levels, so removing them is invisible without a None test.

Change

Unit tests only, in MeasurementScopeExtensionsTests.cs: LogLevel.None returns NullScope.Instance; null logger throws ArgumentNullException("logger"); null identifier throws ArgumentNullException("identifier"); empty/whitespace identifier throws ArgumentException("identifier").

Before / After

metric before after
mutation score 80.00 % 95.00 %
NoCoverage 1 0
survived 3 1
killed 16 19
Stryker time elapsed n/a 37.7 s

Risk / what this does not change

No production code changes. The Stopwatch.Stop survivor is not addressed. Measured on the branch: https://github.com/dailydevops/logging.measurement/actions/runs/40804802841

Run: https://github.com/dailydevops/fluentvalue/actions/runs/40804673608

Survivors in the Stryker report (77.21 %) include the ThrowIfNull guards of
And/Or/Xor/Not operators and ParenthesisConstraint, and the early return in
SetDescription of an operator without right-hand constraint. Add tests for
both. Remove the redundant ThrowIfNull(_constraint) in
ParenthesisConstraint.IsSatisfiedBy (already guaranteed by the ctor guard,
an equivalent mutant).
@samtrion
samtrion requested a review from a team as a code owner October 29, 2026 02:09
@samtrion
samtrion requested a review from Spacemonkay October 29, 2026 02:09
@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 98.53%. Comparing base (b5aad10) to head (bb73d5d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #613      +/-   ##
==========================================
- Coverage   98.54%   98.53%   -0.01%     
==========================================
  Files          22       22              
  Lines         274      273       -1     
  Branches       43       43              
==========================================
- Hits          270      269       -1     
  Misses          1        1              
  Partials        3        3              

☔ 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 1fc32b2 into main Oct 29, 2026
13 checks passed
@samtrion
samtrion deleted the fix/stryker-operator-guard-and-description-tests branch October 29, 2026 15:40
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