Commit 8c33371
authored
🩹 [Patch]: Framework-generated boilerplate code now tested and covered (#113)
Module tests now validate framework-injected boilerplate — type
accelerator registration and OnRemove cleanup — so code coverage
reflects actual test gaps instead of penalizing module authors for
untested framework code.
## New: Type accelerator registration tests
When `Build-PSModule` injects a class exporter region, the module tests
now verify that every public class and enum listed in
`$ExportableClasses` / `$ExportableEnums` is registered as a type
accelerator after import.
```
Context Framework - Type accelerator registration
[+] Should register public class [Book] as a type accelerator
[+] Should register public class [BookList] as a type accelerator
```
Modules without a class exporter region skip these tests automatically.
## New: OnRemove cleanup tests
A new test verifies that when the module is removed, its type
accelerators are cleaned up via the `OnRemove` hook — preventing type
collisions when re-importing or importing a different version.
```
Context Framework - Module OnRemove cleanup
[+] Should clean up type accelerators when the module is removed
```
## Changed: IsWindows compatibility shim removed
The `$IsWindows = $true` PS 5.1 Desktop edition shim has been removed
from `Build-PSModule` (see
[PSModule/Build-PSModule#132](PSModule/Build-PSModule#132)).
The corresponding test context and test fixture output have been removed
here as well. PSModule targets PowerShell LTS (7.6+) where `$IsWindows`
is a built-in automatic variable.
## Technical Details
- `PSModule.Tests.ps1`: Discovery-phase variables (`$hasClassExporter`,
`$expectedClassNames`, `$expectedEnumNames`) are computed at script
scope for Pester's `-Skip`/`-ForEach` evaluation, then recomputed in a
top-level `BeforeAll` for the Run phase. This dual-computation pattern
is required because Pester v5 Discovery and Run are separate executions
that don't share script-scope state.
- `PSModuleTest.psm1` (test fixture): Updated to remove the `$IsWindows`
shim and its suppression attributes, matching the new Build-PSModule
output format.
- PSScriptAnalyzer `PSUseDeclaredVarsMoreThanAssignments` suppressed at
file level because the analyzer cannot trace variable flow across
Pester's `BeforeAll` → `It` block boundaries.1 parent 3cf6c58 commit 8c33371
File tree
2 files changed
+137
-8
lines changed- src/tests/Module/PSModule
- tests/outputTestRepo/outputs/module/PSModuleTest
2 files changed
+137
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
15 | 49 | | |
16 | 50 | | |
17 | 51 | | |
18 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
19 | 70 | | |
20 | 71 | | |
21 | 72 | | |
22 | 73 | | |
23 | 74 | | |
24 | | - | |
| 75 | + | |
25 | 76 | | |
26 | 77 | | |
27 | 78 | | |
| |||
36 | 87 | | |
37 | 88 | | |
38 | 89 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
43 | 130 | | |
44 | 131 | | |
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
380 | 422 | | |
381 | 423 | | |
382 | 424 | | |
| |||
0 commit comments