Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,26 @@ applyTo: "**/*.[Tt]ests.ps1"

## Syntax Rules
- PascalCase: `Describe`, `Context`, `It`, `Should`, `BeforeAll`, `BeforeEach`, `AfterAll`, `AfterEach`
- Use `-BeTrue`/`-BeFalse` never `-Be $true`/`-Be $false`
- Use `-BeTrue`/`-BeFalse` never `-Be $true`/`-Be $false`/`-Contain $true`/`-Contain $false`
- Never use `Assert-MockCalled`, use `Should -Invoke` instead
- No `Should -Not -Throw` - invoke commands directly
- Never add an empty `-MockWith` block
- Omit `-MockWith` when returning `$null`
- Set `$PSDefaultParameterValues` for `Mock:ModuleName`, `Should:ModuleName`, `InModuleScope:ModuleName`
- Omit `-ModuleName` parameter on Pester commands
- Never use `Mock` inside `InModuleScope`-block
- Never use `param()` inside `-MockWith` scriptblocks, parameters are auto-bound
- Never use `param()`-block inside `-MockWith` scriptblocks, parameters are auto-bound
- In `InModuleScope` tests, add `Set-StrictMode -Version 1.0` immediately before invoking the tested function
- Use `Should -Invoke -Exactly -Times <n> -Scope It` for call-count assertions
- Assert <n> calls inside the `It` block; do not assert call counts across an entire `Describe` or `Context`

## File Organization
- Class resources: `tests/Unit/Classes/{Name}.Tests.ps1`
- Public commands: `tests/Unit/Public/{Name}.Tests.ps1`
- Private functions: `tests/Unit/Private/{Name}.Tests.ps1`

## Data-Driven Tests (Test Cases)
- Define `-ForEach` variables in `BeforeDiscovery` (close to usage)
- Define `-ForEach` variables in separate `BeforeDiscovery` (close to usage)
- `-ForEach` allowed on `Context` and `It` blocks
Comment thread
johlju marked this conversation as resolved.
- Never add `param()` inside Pester blocks when using `-ForEach`
- Access test case properties directly: `$PropertyName`
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- SqlServerDsc
- Updated Pester test guidance in AI instructions in community style guidelines.

## [17.5.0] - 2026-01-30

### Changed
Expand Down
Loading