Skip to content

test: make AppendFormat provider tests independent of ICU culture data - #442

Closed
samtrion wants to merge 1 commit into
mainfrom
fix/stryker-culture-dependent-tests-abort-initial-run
Closed

samtrion wants to merge 1 commit into
mainfrom
fix/stryker-culture-dependent-tests-abort-initial-run

Conversation

@samtrion

@samtrion samtrion commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem

ThrowIfInPast / ThrowIfInFuture (ArgumentOutOfRangeExceptionPolyfills.cs, #if NET8_0_OR_GREATER) leave surviving mutants in the Stryker report: null-coalescing (timeProvider ?? TimeProvider.System) in all 6 overloads, </> boundary equality mutants for DateTime and DateTimeOffset, and exception message string mutants. The 17-survivor figure comes from the Stryker report (not present in the run log); the overall latest mutation score of this repo is 27.10%.

Root cause

No test passes a TimeProvider, so the parameter is effectively untested, and the real clock cannot produce a value exactly equal to "now".

Change

Tests only, in the two existing files ArgumentOutOfRangeException_ThrowIfInPastTests.cs and ..._ThrowIfInFutureTests.cs: a small private TimeProvider subclass returning a fixed instant (2100-01-01 for InPast, 2000-01-01 for InFuture, so the result differs from the real clock). For DateOnly, DateTime and DateTimeOffset: value == now does not throw; value one tick/day off throws, with Message.Contains("Value must not be in the past/future"). No new dependency.

Before / After

metric before after
Survivors in ArgumentOutOfRangeExceptionPolyfills.cs (est. from report) 17 pending
Overall mutation score 27.10% pending

Risk / what this does not change

Test-only change; no production code touched. Kill counts are estimates until the mutation run on this branch completes.

Measured run: https://github.com/dailydevops/codebuilder/actions/runs/40805858858 (dispatch on this branch, success, about 6 min). As expected the score is unchanged; the CI run cannot show the invariant=1 benefit, which is shown by the local test results above.

The five AppendFormat_WithProvider_* tests used new CultureInfo("de-DE")
and asserted "1.234,56". With DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 this
culture is unavailable, so the tests error out and the Stryker initial test
run aborts ("more than 50% failing tests").

Use an explicit NumberFormatInfo (and an invariant-culture clone carrying it
for the CurrentCulture test) so the suite passes with or without ICU.
Assertions are unchanged.
@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 91.76%. Comparing base (0caae59) to head (11de797).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #442   +/-   ##
=======================================
  Coverage   91.76%   91.76%           
=======================================
  Files          15       15           
  Lines         340      340           
  Branches      100      100           
=======================================
  Hits          312      312           
  Misses         17       17           
  Partials       11       11           

☔ 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 closed this Oct 29, 2026
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