Skip to content

test: raise Humanizer coverage above 99 percent#1727

Merged
clairernovotny merged 9 commits into
mainfrom
codex/coverage-99
Apr 18, 2026
Merged

test: raise Humanizer coverage above 99 percent#1727
clairernovotny merged 9 commits into
mainfrom
codex/coverage-99

Conversation

@clairernovotny

Copy link
Copy Markdown
Member

Summary

  • add focused coverage-gap tests for converter fallback, overflow, truncation, registry, formatter, and fluent date generated APIs
  • refactor token-map source-generator emission helpers to reduce per-method branching
  • normalize formatter-required EOF/style issues in touched test surface

Tests

  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --coverage --coverage-output-format cobertura (99.0006% line coverage)
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net11.0 -c Release
  • DOTNET_ROLL_FORWARD=Major dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net8.0 -c Release
  • dotnet test tests/Humanizer.SourceGenerators.Tests/Humanizer.SourceGenerators.Tests.csproj -c Release
  • dotnet format Humanizer.slnx --verify-no-changes --verbosity diagnostic
  • dotnet pack src/Humanizer/Humanizer.csproj -c Release -o artifacts/package-validation
  • pwsh tests/verify-packages.ps1 -PackageVersion 3.5.0-preview.2.g30d00a7bd9 -PackagesDirectory artifacts/package-validation

Notes

  • Exact net8.0 test launch is blocked on this machine because Microsoft.NETCore.App 8.0.0 is not installed; the net8.0 target was also run with DOTNET_ROLL_FORWARD=Major.
  • net48 tests were not run because this is not a Windows host.

Copilot AI review requested due to automatic review settings April 17, 2026 20:15
Comment thread tests/Humanizer.Tests/CoverageGapTests.cs Fixed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds targeted tests and small generator refactors to push Humanizer’s line coverage above 99%, while also normalizing formatting in touched test files.

Changes:

  • Added new “coverage gap” tests exercising fallback/edge branches across converters, truncation, registries, and formatter behaviors.
  • Added reflection-based tests to cover the generated FluentDate API surface (including DateOnly/TimeOnly paths behind TFMs).
  • Refactored token-map source-generator emission helpers to reduce per-locale branching; normalized EOF/style in a few test files.

Reviewed changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/Humanizer.Tests/Localisation/ur/UrduListHumanizeTests.cs EOF/style normalization only.
tests/Humanizer.Tests/Localisation/FormatterExactOutputTests.cs EOF/style normalization only.
tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs New tests reflecting over FluentDate generated API surface.
tests/Humanizer.Tests/CoverageGapTests.cs New broad set of focused tests covering previously-unhit branches.
tests/Humanizer.Tests/CollectionHumanizeTests.cs EOF/style normalization only.
tests/Humanizer.SourceGenerators.Tests/SourceGenerators/HumanizerSourceGeneratorTests.cs Renamed cached generated source field to match naming rules; updated references.
src/Humanizer.SourceGenerators/Generators/TokenMapWordsToNumberInput.cs Refactored generator emission to use helper for “true” booleans and simplified long emission for ScaleThreshold.
src/Humanizer.SourceGenerators/Generators/ProfileCatalogs/WordsToNumberEngineContractFactory.cs Refactored token-map rules expression generation to reduce per-field branching and centralize literal formatting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs
Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs
Comment thread tests/Humanizer.Tests/CoverageGapTests.cs
Comment thread tests/Humanizer.Tests/CoverageGapTests.cs Outdated
Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs
Copilot AI review requested due to automatic review settings April 17, 2026 21:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs Outdated
Comment thread tests/Humanizer.Tests/CoverageGapTests.cs Outdated
Copilot AI review requested due to automatic review settings April 17, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs Outdated
Comment thread tests/Humanizer.Tests/FluentDate/GeneratedFluentDateTests.cs Outdated
Copilot AI review requested due to automatic review settings April 18, 2026 01:22
@clairernovotny

Copy link
Copy Markdown
Member Author

Follow-up pushed in 4568d13a04a75bced8fcf69b40ecd0ca495eac99.

Coverage/complexity checkpoint from local net10.0 Cobertura:

  • Line: 99.7057% (17958/18011, 53 missed).
  • Branch: 97.1742% (5846/6016, 170 missed). This is a reasonable intermediate branch target for this PR: hold at/above 97% while the remaining branch gaps are handled in smaller source-focused follow-ups.
  • Total Cobertura complexity dropped from 7848 to 6806.
  • The three generated catalog dispatch files no longer use giant switches; each now reports 100% branch coverage and complexity 2 in the class entries.

Validation run locally:

  • dotnet test tests/Humanizer.SourceGenerators.Tests/Humanizer.SourceGenerators.Tests.csproj -c Release
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net11.0 -c Release
  • DOTNET_ROLL_FORWARD=Major dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net8.0 -c Release
  • dotnet format Humanizer.slnx --verify-no-changes --verbosity minimal
  • dotnet pack src/Humanizer/Humanizer.csproj -c Release -o artifacts/package-validation
  • pwsh -NoProfile -File tests/verify-packages.ps1 -PackageVersion 3.5.0-preview.4.g4568d13a04 -PackagesDirectory artifacts/package-validation

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 16 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clairernovotny

Copy link
Copy Markdown
Member Author

Follow-up pushed in fa1c8144cefa4212e089cfb30735d0d21ace71e7.

Coverage/branch checkpoint from local net10.0 Cobertura:

  • Line: 99.7057% (17958/18011, 53 missed).
  • Branch: 97.7379% (5876/6012, 136 missed). This covers 30 more branches than the prior local checkpoint and removes the formatter collection targets from the active hotspot list.
  • Total Cobertura complexity: 6802.

What changed:

  • Added focused formatter fallback/profile branch tests and public ordinal/null-culture edge coverage.
  • Covered LocalePhraseTable, DelimitedCollectionFormatter, and CliticCollectionFormatter branch gaps; Flow task fn-9-fill-code-coverage-gaps-toward-95-line.6 is marked done.
  • Fixed Func<T, object?> collection formatter overloads to throw ArgumentNullException for a null formatter instead of null-dereferencing.
  • Added scripts/coverage-branch-hotspots.ps1 to sort missed Cobertura branch hotspots by file/line for the remaining branch work.

Validation run locally:

  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --filter-class Humanizer.Tests.CoverageGapTests
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net11.0 -c Release
  • DOTNET_ROLL_FORWARD=Major dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net8.0 -c Release
  • dotnet test tests/Humanizer.SourceGenerators.Tests/Humanizer.SourceGenerators.Tests.csproj -c Release
  • dotnet format Humanizer.slnx --verify-no-changes --verbosity minimal
  • git diff --check
  • dotnet pack src/Humanizer/Humanizer.csproj -c Release -o artifacts/package-validation

Copilot AI review requested due to automatic review settings April 18, 2026 06:13
@clairernovotny

Copy link
Copy Markdown
Member Author

Follow-up pushed in 1d4f3843753c2e6486a51d6c3bda8d57e177b958.

Coverage/branch checkpoint from local net10.0 Cobertura:

  • Line: 99.7057% (17958/18011, 53 missed).
  • Branch: 97.9042% (5886/6012, 126 missed). This covers 10 more branches than the prior local checkpoint and moves LongScaleStemOrdinalNumberToWordsConverter from 89.29% to 98.21% branch coverage.
  • Total Cobertura complexity: 6802.

What changed:

  • Added focused Spanish long-scale ordinal tests for abbreviated ordinal units, gendered cardinal units, and round-number boundary shapes.
  • Marked Flow tasks fn-9-fill-code-coverage-gaps-toward-95-line.13 and .15 complete with coverage evidence.

Validation run locally:

  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --filter-class Humanizer.Tests.CoverageGapTests
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net10.0 -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net11.0 -c Release
  • DOTNET_ROLL_FORWARD=Major dotnet test tests/Humanizer.Tests/Humanizer.Tests.csproj --framework net8.0 -c Release
  • dotnet format Humanizer.slnx --verify-no-changes --verbosity minimal
  • dotnet pack src/Humanizer/Humanizer.csproj -c Release -o artifacts/local-pack

Note: a plain local net8.0 launch cannot start on this machine because the .NET 8 runtime is not installed; the roll-forward run passed on the installed newer runtime.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 22 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clairernovotny

Copy link
Copy Markdown
Member Author

Follow-up pushed in 6298523996191163ca3fe4cee5aeef6102ef762e.

Coverage/branch checkpoint from local Cobertura:

  • Source generator targeted files:
    • CanonicalLocaleAuthoring.cs: 91.02% line (517/568), 90.37% branch (338/374).
    • LocaleYamlCatalog.cs: 93.75% line (525/560), 87.58% branch (289/330).
  • Analyzer matrix targeted files, across Roslyn 4.14 / 4.8 / 3.8:
    • WordsToNumberMigrationCodeFixProvider.cs: 100.00% line, 87.50% branch.
    • NamespaceMigrationCodeFixProvider.cs: 96.15% / 96.10% line, 88.46% branch.
    • NamespaceMigrationAnalyzer.cs: 95.83% / 95.71% line, 91.18% branch.

What changed:

  • Added source-generator diagnostics coverage for unsupported canonical surfaces/properties, invalid number formatting, calendar override exception branches, list template validation, legacy migration edge cases, and semantic diff left/right-only locales.
  • Added analyzer/code-fix coverage for WordsToNumber converter casts, non-actionable long invocations, namespace qualified-name parent skipping, exact qualified-name replacement, and helper edge cases across the split Roslyn test projects.
  • Marked Flow tasks fn-9-fill-code-coverage-gaps-toward-95-line.8 and .16 done with evidence.

Validation run locally:

  • dotnet test tests/Humanizer.SourceGenerators.Tests/Humanizer.SourceGenerators.Tests.csproj -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.SourceGenerators.Tests/Humanizer.SourceGenerators.Tests.csproj -c Release
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn414.csproj -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn48.csproj -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn38.csproj -c Release -- --coverage --coverage-output-format cobertura
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn414.csproj -c Release
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn48.csproj -c Release
  • dotnet test tests/Humanizer.Analyzers.Tests/Humanizer.Analyzers.Tests.Roslyn38.csproj -c Release
  • dotnet format Humanizer.slnx --verify-no-changes --verbosity diagnostic
  • git diff --check
  • dotnet pack src/Humanizer/Humanizer.csproj -c Release -o artifacts/package-coverage
  • pwsh -NoLogo -NoProfile -File tests/verify-packages.ps1 -PackageVersion 3.5.0-preview.6.g1d4f384375 -PackagesDirectory artifacts/package-coverage

GitHub checks are running on the new SHA now.

Copilot AI review requested due to automatic review settings April 18, 2026 07:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings April 18, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@clairernovotny clairernovotny merged commit e501513 into main Apr 18, 2026
7 checks passed
@clairernovotny clairernovotny deleted the codex/coverage-99 branch April 18, 2026 08:55
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.

3 participants