Skip to content

[Issue]: Add code coverage reporting to Pester workflow (stretch goal) #201

@WilliamBerryiii

Description

@WilliamBerryiii

Summary

Add code coverage reporting to the Pester testing workflow, tracking coverage metrics over time.

Parent Issue: #190

Note: This is a stretch goal / future enhancement. Implement after core testing is established.

Requirements

  • Configure Pester to generate JaCoCo XML coverage reports
  • Upload coverage reports as workflow artifacts
  • Optionally integrate with coverage tracking service (Codecov, Coveralls)
  • Establish baseline coverage thresholds

Implementation Details

Pester Coverage Configuration

# In pester.config.ps1
$config = New-PesterConfiguration

$config.CodeCoverage.Enabled = $true
$config.CodeCoverage.OutputFormat = 'JaCoCo'
$config.CodeCoverage.OutputPath = 'logs/coverage.xml'
$config.CodeCoverage.Path = @(
    './scripts/linting/*.ps1'
    './scripts/linting/Modules/*.psm1'
    './scripts/security/*.ps1'
    './scripts/dev-tools/*.ps1'
    './scripts/extension/*.ps1'
    './scripts/lib/*.ps1'
)

# Optional: Set coverage threshold
$config.CodeCoverage.CoveragePercentTarget = 80

Workflow Integration

- name: Run Pester Tests with Coverage
  shell: pwsh
  run: |
    $config = . ./scripts/tests/pester.config.ps1
    $config.CodeCoverage.Enabled = $true
    Invoke-Pester -Configuration $config

- name: Upload Coverage Report
  uses: actions/upload-artifact@... # SHA-pinned
  if: always()
  with:
    name: coverage-report
    path: logs/coverage.xml

# Optional: Codecov integration
- name: Upload to Codecov
  uses: codecov/codecov-action@... # SHA-pinned
  with:
    files: logs/coverage.xml
    flags: powershell

Coverage Thresholds

Suggested initial thresholds:

  • Overall: 70%
  • Per-file minimum: 50%
  • Target (after all sub-issues complete): 80%

Acceptance Criteria

  • Pester configuration includes coverage settings
  • JaCoCo XML coverage report generated
  • Coverage report uploaded as artifact
  • Optional: Coverage service integration configured
  • Coverage threshold enforcement (warn or fail)

Dependencies

Estimated Effort

1-2 hours


Additional Context

Why Stretch Goal

Code coverage is valuable but:

  1. Requires all tests to exist first
  2. May need external service account setup
  3. Threshold tuning requires baseline data

Implement after core testing infrastructure is proven.

Coverage Report Formats

  • JaCoCo XML: Industry standard, supported by most services
  • Cobertura: Alternative format if needed
  • HTML: Local viewing (not for CI)

Related Issues

Metadata

Metadata

Labels

enhancementNew feature or requestworkflowsGitHub Actions workflows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions