You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b158a53
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/content/reference/test-specification.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,43 +2,43 @@
2
2
3
3
## Overview
4
4
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.
6
6
7
7
## Test Structure
8
8
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:
10
10
11
11
### 1. Module-Level `Describe`
12
12
13
13
- 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.
15
15
16
16
### 2. Function-Level `Describe`
17
17
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.
20
20
21
21
### 3. Use Case `Context`
22
22
23
-
-Each use case is grouped within a `Context` block.
23
+
-Group each use case in a `Context` block.
24
24
- The context name starts with the function name followed by a descriptive test case identifier.
25
25
- Example: `Get-Uri - simple usage`
26
26
- Example: `Get-Uri - Pipeline usage`
27
27
- Example: `Get-Uri - ParameterSet: Detailed`
28
28
29
29
### 4. Functional `It` Statements
30
30
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.
32
32
- The name follows the format: `FunctionName - <expected behavior>`
33
33
- Example: `Get-Uri - gets the URI object when provided a string`
34
34
- Example: `Get-Uri - returns $null when input is empty`
35
35
- Example: `Get-Uri - throws error on invalid input`
36
36
37
37
### 5. Test Guidelines
38
38
39
-
-**No Mocks**: We do not use mocks in tests.
39
+
-**No Mocks**: Do not use mocks in tests.
40
40
-**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.
42
42
43
43
## Example Test Structure
44
44
@@ -62,4 +62,4 @@ Describe 'Uri' {
62
62
}
63
63
```
64
64
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