You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Math]::Truncate of a fractional value is 0, so $percent is 0 for any coverage below exactly 100%. Two user-facing consequences:
The printed per-counter report always shows 0.00% (or 100.00%) regardless of real coverage
The CodeCoverageThreshold comparison ($_.percent -lt $CodeCoverageThreshold) fails for any nonzero threshold unless coverage is exactly 100% — so consumers who set, say, 0.8 get a failing build even at 95% coverage
Suggested fix
Compute the ratio as a floating-point value and drop the truncation ($percent = $_.covered / $total), or round to a sensible precision. The {2:p} format string already handles percent rendering.
Notes
Related history: Addressing Issue #61 - update CodeCoverage Output File Format to fix error #62 fixed the coverage output path/format; Tests: Test-PSBuildPester #102 added regression tests for output path/format but not for the threshold math — the fix should come with a test-first regression test in tests/Test-PSBuildPester.tests.ps1 (a subprocess scenario with partial coverage and a threshold below it must pass; a threshold above it must fail)
Found while evaluating repository-side coverage tracking; the shipped coverage measurement works, it is the report/threshold arithmetic that is wrong
Test-PSBuildPestercomputes each coverage percentage like this when building its threshold report:[Math]::Truncateof a fractional value is0, so$percentis0for any coverage below exactly 100%. Two user-facing consequences:0.00%(or100.00%) regardless of real coverageCodeCoverageThresholdcomparison ($_.percent -lt $CodeCoverageThreshold) fails for any nonzero threshold unless coverage is exactly 100% — so consumers who set, say,0.8get a failing build even at 95% coverageSuggested fix
Compute the ratio as a floating-point value and drop the truncation (
$percent = $_.covered / $total), or round to a sensible precision. The{2:p}format string already handles percent rendering.Notes
tests/Test-PSBuildPester.tests.ps1(a subprocess scenario with partial coverage and a threshold below it must pass; a threshold above it must fail)