tune-pester-test-development — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited tune-pester-test-development (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
| Metric | Minimum | Warning | Target | Action if Below |
|---|---|---|---|---|
| Line coverage | 85% | 88% | ≥90% | Generate targeted tests for missed lines |
| Branch coverage | 70% | 75% | ≥80% | Add Context blocks for each branch |
| Function coverage | 95% | 98% | 100% | Add Describe block for each untested function |
| Test pass rate | 99% | 99.5% | 100% | Fix failing assertions and mock setup |
| Avg test duration | <10s | <5s | <2s | Share mocks, reduce I/O, parallelize |
| Flaky test rate | <2% | <1% | 0% | Replace timing deps with mocks |
$config = New-PesterConfiguration
$config.Run.Path = './tests'
$config.Run.PassThru = $true
$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.Path = './src'
$result = Invoke-Pester -Configuration $config
# Group missed commands by file
$missed = $result.CodeCoverage.CommandsMissed
$grouped = $missed | Group-Object File | Sort-Object Count -Descending
foreach ($file in $grouped) {
Write-Host "`n--- $($file.Name) ($($file.Count) uncovered lines) ---"
$file.Group | ForEach-Object {
Write-Host " L$($_.Line): $($_.Command)"
}
}Context 'When API call fails' {
BeforeAll {
Mock Get-AzResource { throw 'Service unavailable' }
}
It 'Throws meaningful error' {
{ Get-ResourceStatus -Name 'test' } | Should -Throw '*unavailable*'
}
It 'Does not call downstream functions' {
Should -Invoke Process-Resource -Times 0
}
}Context 'When resource does not exist' {
BeforeAll {
Mock Get-AzResource { $null } # Triggers the else branch
}
It 'Returns not-found status' {
$result = Get-ResourceStatus -Name 'missing'
$result.Status | Should -Be 'NotFound'
}
}It 'Handles all severity levels' -TestCases @(
@{ Severity = 'Critical'; Expected = 1 }
@{ Severity = 'Warning'; Expected = 2 }
@{ Severity = 'Info'; Expected = 3 }
) {
Get-SeverityCode -Severity $Severity | Should -Be $Expected
}InModuleScope 'MyModule' {
Describe 'Internal: Format-OutputRecord' {
It 'Formats record with timestamp' {
$result = Format-OutputRecord -Data @{ Name = 'test' }
$result.Timestamp | Should -Not -BeNullOrEmpty
}
}
}Context 'Pipeline input' {
It 'Processes multiple items from pipeline' {
$items = @('item1', 'item2', 'item3')
$results = $items | Get-ProcessedItem
$results.Count | Should -Be 3
}
}| Failure Message | Root Cause | Fix |
|---|---|---|
Expected 'X' but got $null | Mock not returning value | Add return object to Mock: Mock Fn { @{...} } |
CommandNotFoundException | Source not dot-sourced | Add . $PSScriptRoot/../src/Fn.ps1 to BeforeAll |
Cannot bind parameter | Wrong parameter type | Check parameter types, use correct test data |
Mock was called 0 times | Function not calling the mock | Verify function actually calls the mocked cmdlet |
Expected Throw but no exception | ErrorAction not Stop | Add -ErrorAction Stop in source function |
Cannot find module | Module not imported | Add Import-Module ./src/MyModule.psd1 to BeforeAll |
# BEFORE (flaky — depends on actual time)
It 'Returns recent items' {
$result = Get-RecentItems -Hours 24
$result | Should -Not -BeNullOrEmpty
}
# AFTER (deterministic — mocked time)
It 'Returns recent items' {
Mock Get-Date { [DateTime]'2026-04-10T12:00:00' }
$result = Get-RecentItems -Hours 24
$result | Should -Not -BeNullOrEmpty
}# Ensure each Context has complete setup — no reliance on other tests
Context 'Scenario A' {
BeforeAll {
# COMPLETE mock setup for this scenario
Mock Get-AzResource { @{ Name = 'res1' } }
Mock Get-AzContext { @{ Subscription = @{ Id = '...' } } }
}
# Tests here are fully isolated
}Describe 'Get-AllResources' -Tag 'Unit' {
BeforeAll {
# SHARED — set up once for all Contexts
Mock Connect-AzAccount { }
Mock Get-AzContext { @{ Subscription = @{ Id = '...' } } }
}
Context 'Specific scenario' {
BeforeAll {
# SCENARIO-SPECIFIC — override only what changes
Mock Get-AzResource { @{ Name = 'test' } }
}
}
}# Use TestDrive (RAM-backed) instead of real file system
BeforeAll {
Set-Content "TestDrive:/data.json" '{"items":[1,2,3]}'
}$config = New-PesterConfiguration
$config.Run.Path = './tests'
# Each .Tests.ps1 file runs as a separate container (parallelizable in CI)Track coverage over time to prevent regression:
# Compare current vs baseline
$baseline = 90.0 # Last known good coverage
$current = $pct # From Invoke-Pester result
if ($current -lt $baseline) {
Write-Error "Coverage REGRESSION: $current% < baseline $baseline%"
} elseif ($current -gt $baseline) {
Write-Host "Coverage IMPROVED: $current% (was $baseline%)"
} else {
Write-Host "Coverage STABLE: $current%"
}## Tuning Report
| Action | Before | After | Change |
|---------------------------|--------|-------|--------|
| Line coverage | 78% | 93% | +15% |
| Branch coverage | 65% | 85% | +20% |
| Failing tests | 3 | 0 | Fixed |
| Flaky tests | 2 | 0 | Fixed |
| Avg test duration | 4.2s | 1.8s | -57% |
| New tests generated | — | 12 | Added |~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.