Skip to content

Document -ErrorAction soft-assertion behavior on Should-* commands#2835

Merged
nohwnd merged 1 commit into
pester:mainfrom
nohwnd:nohwnd-sturdy-funicular
Jul 3, 2026
Merged

Document -ErrorAction soft-assertion behavior on Should-* commands#2835
nohwnd merged 1 commit into
pester:mainfrom
nohwnd:nohwnd-sturdy-funicular

Conversation

@nohwnd

@nohwnd nohwnd commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Surfaces the per-assertion meaning of -ErrorAction on the Should-* assertions by adding a NOTES section to their comment-based help. Today -ErrorAction only appears in the generic common-parameters boilerplate on the auto-generated Command Reference pages, with no hint that for assertions it is the knob that controls soft-assertion behavior.

Each Should-* help now explains:

  • -ErrorAction Continue — record the failure but keep running the test (soft assertion)
  • -ErrorAction Stop — fail the test immediately (e.g. to guard a precondition before continuing)
  • when -ErrorAction is not specified, the behavior comes from Should.ErrorAction in the configuration (default Stop)

The note links to the dedicated https://pester.dev/docs/assertions/soft-assertions page.

Why

This is Part 1 of pester/docs#385. Part 2 (a dedicated, searchable "Soft assertions" page) already shipped in the docs repo (pester/docs#397). Part 1 has to land here because the Should-* Command Reference pages are auto-generated from this comment-based help — so the text change can't be made in the docs repo.

Scope

  • Adds a .NOTES section to the 21 Should-* assertions that didn't have one, and appends the same two paragraphs to the existing .NOTES of the other 20. 41 files, additive only (no logic changes).
  • Wording matches the mechanism in Invoke-AssertionFailed (-ErrorAction Stop → throw; otherwise collected; falls back to Should.ErrorAction).

Verification

  • All 41 files parse with no errors.
  • Get-Help shows the new NOTES on all 41 commands.
  • tst/Help.Tests.ps1 -Tag Help passes: 390 passed, 0 failed, 1 skipped.

Add a NOTES section to the comment-based help of every Should-* assertion
explaining that the -ErrorAction common parameter controls soft-assertion
behavior:

- -ErrorAction Continue records the failure and lets the rest of the test
  run (a soft assertion)
- -ErrorAction Stop fails the test immediately (e.g. to guard a precondition)
- when -ErrorAction is not specified, the behavior comes from
  Should.ErrorAction in the configuration (default Stop)

These NOTES surface on the auto-generated Command Reference pages at
pester.dev (e.g. Should-Be), addressing Part 1 of pester/docs#385.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd merged commit 1ec1012 into pester:main Jul 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant