Skip to content

Commit b158a53

Browse files
State Pester test rules without vague assurances
1 parent 8d148a4 commit b158a53

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

‎docs/content/reference/test-specification.md‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22

33
## Overview
44

5-
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.
5+
This specification defines the Pester test hierarchy, input guidance, and coverage requirements for PowerShell functions.
66

77
## Test Structure
88

9-
Each function is tested within a structured Pester `Describe` block that follows this hierarchy:
9+
Organize each function's Pester tests in the following hierarchy:
1010

1111
### 1. Module-Level `Describe`
1212

1313
- The outermost `Describe` block corresponds to the module.
14-
- The module name is derived from the prefix of the function name's noun part.
14+
- Use the prefix of the function name's noun part as the module name.
1515

1616
### 2. Function-Level `Describe`
1717

18-
- Each function within the module gets its own `Describe` block.
19-
- Named using the full function name.
18+
- Give each function in the module its own `Describe` block.
19+
- Use the full function name as the block name.
2020

2121
### 3. Use Case `Context`
2222

23-
- Each use case is grouped within a `Context` block.
23+
- Group each use case in a `Context` block.
2424
- The context name starts with the function name followed by a descriptive test case identifier.
2525
- Example: `Get-Uri - simple usage`
2626
- Example: `Get-Uri - Pipeline usage`
2727
- Example: `Get-Uri - ParameterSet: Detailed`
2828

2929
### 4. Functional `It` Statements
3030

31-
- Each `It` block tests a specific aspect of the function's behavior.
31+
- Each `It` block tests one aspect of the function's behavior.
3232
- The name follows the format: `FunctionName - <expected behavior>`
3333
- Example: `Get-Uri - gets the URI object when provided a string`
3434
- Example: `Get-Uri - returns $null when input is empty`
3535
- Example: `Get-Uri - throws error on invalid input`
3636

3737
### 5. Test Guidelines
3838

39-
- **No Mocks**: We do not use mocks in tests.
39+
- **No Mocks**: Do not use mocks in tests.
4040
- **Real Inputs**: Tests should use actual inputs and expected outputs.
41-
- **Comprehensive Coverage**: All function functionality, including edge cases, must be tested.
41+
- **Comprehensive Coverage**: Tests must cover all function behavior, including edge cases.
4242

4343
## Example Test Structure
4444

@@ -62,4 +62,4 @@ Describe 'Uri' {
6262
}
6363
```
6464

65-
This ensures our tests are structured, maintainable, and adhere to best practices.
65+
The example groups `Get-Uri` tests under the `Uri` module and uses separate contexts for direct and pipeline input.

0 commit comments

Comments
 (0)