diff --git a/src/docs/PowerShell/Modules/Test-Specification.md b/src/docs/PowerShell/Modules/Test-Specification.md index d08eb9b..870e3f7 100644 --- a/src/docs/PowerShell/Modules/Test-Specification.md +++ b/src/docs/PowerShell/Modules/Test-Specification.md @@ -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: