Status: active
Priority: P0 (blocker - technical debt)
Complexity: Low (< 30 minutes)
Type: Bug Fix
When running Invoke-Tests.ps1 -Coverage, PowerShell throws a non-fatal warning:
Invoke-Tests.ps1: Cannot convert value "Pester.CodeCoverage" to type
"System.Management.Automation.SwitchParameter". Boolean parameters accept
only Boolean values and numbers, such as $True, $False, 1 or 0.
Impact:
⚠️ Console output pollution⚠️ Confusing for users⚠️ May indicate type system issue- ✅ Functionality works (tests + coverage both OK)
Line 52 in scripts/Invoke-Tests.ps1:
[Parameter()]
[switch]$Coverage,PowerShell's parameter binding has edge cases with [switch] type conversion in certain contexts (likely tab-completion or parameter validation).
Option A: Change to [bool] with default (Recommended)
[Parameter()]
[bool]$Coverage = $false,Option B: Keep [switch], suppress warning
[Parameter()]
[switch]$Coverage
# Add: $ErrorActionPreference = 'SilentlyContinue' before param bindingRecommendation: Option A - more explicit, cleaner semantics.
File: scripts/Invoke-Tests.ps1
Line: 52
Change:
# Before
[Parameter()]
[switch]$Coverage,
# After
[Parameter()]
[bool]$Coverage = $false,File: scripts/Invoke-Tests.ps1
Lines: 12-13
Update .PARAMETER section:
.PARAMETER Coverage
Generate code coverage report (HTML + XML). Default: $falseTest all invocation patterns:
# Should work
./scripts/Invoke-Tests.ps1 -Coverage # -Coverage = $true
./scripts/Invoke-Tests.ps1 -Coverage:$true # Explicit
./scripts/Invoke-Tests.ps1 -Coverage:$false # Explicit
./scripts/Invoke-Tests.ps1 # No coverage
# Should work (PowerShell coercion)
./scripts/Invoke-Tests.ps1 -Coverage 1 # = $true
./scripts/Invoke-Tests.ps1 -Coverage 0 # = $falseVerify GitHub Actions workflow still works:
- File:
.github/workflows/tests.yml - Line: 53:
./scripts/Invoke-Tests.ps1 -Coverage
No unit test needed - parameter validation is PowerShell's responsibility.
# Test 1: Coverage enabled
pwsh -NoProfile -File ./scripts/Invoke-Tests.ps1 -Coverage
# Expected: No warning, coverage report generated
# Test 2: Coverage disabled
pwsh -NoProfile -File ./scripts/Invoke-Tests.ps1
# Expected: No warning, no coverage report
# Test 3: Explicit true
pwsh -NoProfile -File ./scripts/Invoke-Tests.ps1 -Coverage:$true
# Expected: No warning, coverage report generated
# Test 4: Explicit false
pwsh -NoProfile -File ./scripts/Invoke-Tests.ps1 -Coverage:$false
# Expected: No warning, no coverage report- No PowerShell warning when running with
-Coverage - Coverage report still generated correctly
- All existing usage patterns still work
- Help documentation accurate
- CI pipeline passes
- Parameter changed from
[switch]to[bool] - Default value
$falseadded - Help documentation updated
- Manual testing completed (all 4 scenarios)
- CI pipeline passes on GitHub
- No warnings in console output
- Code committed with clear message
- Task moved to
todo/done/
| File | Lines | Change Type |
|---|---|---|
scripts/Invoke-Tests.ps1 |
52 | Parameter type change |
scripts/Invoke-Tests.ps1 |
12-13 | Documentation update |
Blocks: None Blocked By: None Related:
- 005-testing-infrastructure.md - Created this script
Likelihood: Low Impact: Medium Mitigation:
[bool]parameters accept same values as[switch]- PowerShell coerces
-Coverageto-Coverage:$true - Test all invocation patterns before commit
Likelihood: Very Low Impact: Medium Mitigation:
- CI uses
-Coverage(no explicit true/false) - This works with both
[switch]and[bool] - Test locally before push
- PowerShell about_Functions_Advanced_Parameters
- PowerShell about_Switch
| Aspect | [switch] | [bool] |
|---|---|---|
| Default value | Always $false | Can specify explicit default |
| Clarity | Implicit | Explicit |
| Type safety | Less strict | More strict |
| Edge cases | Can have conversion issues | Cleaner semantics |
| Best for | Optional flags | Parameters with defaults |
- Bug discovered during linter integration
- Low effort, high value fix
- Improves code quality and user experience
- No dependencies or blockers
- ✅ Zero PowerShell warnings when running tests
- ✅ 100% backward compatibility maintained
- ✅ CI pipeline success rate unchanged
- ✅ Developer experience improved (cleaner output)