Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/docs/PowerShell/Modules/Test-Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

This document defines the structure and guidelines for writing Pester tests for PowerShell functions. The goal is to ensure consistency and comprehensive test coverage while maintaining clarity.

## Pester version

Lock the test framework to a **major version** so a new Pester major cannot be adopted silently and break every suite at once. Declare it as the first line of each `*.Tests.ps1` file:

```powershell
#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '6.0.0'; MaximumVersion = '6.*' }
```

- `ModuleVersion` + `MaximumVersion` accept any Pester `6.x`, so routine minor and patch updates flow in without a change here — only a new major requires a deliberate, reviewed bump.
- The `MaximumVersion = '6.*'` wildcard locks to the major without a sentinel version; PowerShell enforces the range at discovery time.
- The [Invoke-Pester](https://github.com/PSModule/Invoke-Pester) action installs a matching `6.x`, so the requirement and the installed version stay aligned.
- Pinning module identity with a `GUID` is a separate, stricter supply-chain control — omit it for the default major-lock; add it only when identity assurance is required.

## Test Structure

Each function is tested within a structured Pester `Describe` block that follows this hierarchy:
Expand Down