The module-local setup/teardown model assumes tests/BeforeAll.ps1 prepares state and tests/AfterAll.ps1 cleans up any created resources.
Request
When BeforeAll fails, Test-ModuleLocal should be treated as blocked by a catastrophic setup failure.
Current behavior allows test execution semantics that do not clearly enforce setup-as-gate, and this can produce noisy/invalid test runs after failed setup. Cleanup still needs to run to remove partially created resources.
From observed failure output (run 29487711781 / job 87586287510):
BeforeAll script failed: tests/BeforeAll.ps1 - Cannot bind argument to parameter 'Token' because it is null.
Desired experience
- A failed
BeforeAll is treated as catastrophic for module-local tests
Test-ModuleLocal does not run when BeforeAll fails
AfterAll-ModuleLocal still runs (best-effort cleanup)
- Final workflow summary clearly states setup failure as the root cause
Why this matters
Running tests after setup failure can produce misleading failures and can leave test resources behind if cleanup is not guaranteed.
Acceptance criteria
Test-ModuleLocal is skipped when BeforeAll-ModuleLocal fails
AfterAll-ModuleLocal runs with always() semantics even when BeforeAll-ModuleLocal fails
AfterAll-ModuleLocal can access required context/secrets for cleanup in this failure path
- Workflow summary includes a clear catastrophic setup-failure message
- Overall workflow concludes as failed because setup failed (even if cleanup succeeds)
Technical decisions
Setup failure as hard gate: Treat BeforeAll-ModuleLocal failure as a hard prerequisite failure for test execution.
Cleanup must be independent of test execution: Keep AfterAll-ModuleLocal wired with always() and dependency conditions that permit execution after setup failure.
Explicit status propagation: Introduce/propagate a setup status flag (or rely on job result conditions) so downstream jobs and summary logic can distinguish:
- setup failed
- tests skipped due to setup failure
- cleanup executed (success/failure)
Accurate final reporting: Ensure the final summarization step reports setup failure as root cause and does not mask it behind skipped tests.
Non-breaking for happy path: Existing behavior remains unchanged when BeforeAll succeeds.
Implementation plan
Workflow gating
Cleanup path
Summary and status
Tests
The module-local setup/teardown model assumes
tests/BeforeAll.ps1prepares state andtests/AfterAll.ps1cleans up any created resources.Request
When
BeforeAllfails,Test-ModuleLocalshould be treated as blocked by a catastrophic setup failure.Current behavior allows test execution semantics that do not clearly enforce setup-as-gate, and this can produce noisy/invalid test runs after failed setup. Cleanup still needs to run to remove partially created resources.
From observed failure output (run 29487711781 / job 87586287510):
BeforeAll script failed: tests/BeforeAll.ps1 - Cannot bind argument to parameter 'Token' because it is null.Desired experience
BeforeAllis treated as catastrophic for module-local testsTest-ModuleLocaldoes not run whenBeforeAllfailsAfterAll-ModuleLocalstill runs (best-effort cleanup)Why this matters
Running tests after setup failure can produce misleading failures and can leave test resources behind if cleanup is not guaranteed.
Acceptance criteria
Test-ModuleLocalis skipped whenBeforeAll-ModuleLocalfailsAfterAll-ModuleLocalruns withalways()semantics even whenBeforeAll-ModuleLocalfailsAfterAll-ModuleLocalcan access required context/secrets for cleanup in this failure pathTechnical decisions
Setup failure as hard gate: Treat
BeforeAll-ModuleLocalfailure as a hard prerequisite failure for test execution.Cleanup must be independent of test execution: Keep
AfterAll-ModuleLocalwired withalways()and dependency conditions that permit execution after setup failure.Explicit status propagation: Introduce/propagate a setup status flag (or rely on job result conditions) so downstream jobs and summary logic can distinguish:
Accurate final reporting: Ensure the final summarization step reports setup failure as root cause and does not mask it behind skipped tests.
Non-breaking for happy path: Existing behavior remains unchanged when
BeforeAllsucceeds.Implementation plan
Workflow gating
Test-ModuleLocaljob condition to require successfulBeforeAll-ModuleLocalBeforeAllfailure leads to explicit skip of test job (not ambiguous state)Cleanup path
AfterAll-ModuleLocalcondition includesalways()and allows run after setup failureSummary and status
Tests