Skip to content

Fix four wrong statements in the tutorial - #465

Open
nohwnd wants to merge 1 commit into
nohwnd-tutorial-copy-blocksfrom
nohwnd-tutorial-wrong-statements
Open

Fix four wrong statements in the tutorial#465
nohwnd wants to merge 1 commit into
nohwnd-tutorial-copy-blocksfrom
nohwnd-tutorial-wrong-statements

Conversation

@nohwnd

@nohwnd nohwnd commented Aug 29, 2026

Copy link
Copy Markdown
Member

Fix #460

Stacked on #464, review that one first. The diff against main will look bigger than it is until #464 merges.

I verified the tutorial by running it against Pester 6.1.0. Almost everything holds up, every test total and every coverage number is right. These four were wrong.

The -ModuleName warning. It said "Nothing errors. The mock is simply never used, and the real command runs instead." True for a command that also exists outside the module, and the box sits under the Get-PlanetData example, which is private. There Mock cannot find the command at all:

CommandNotFoundException: Could not find Command Get-PlanetData

Both cases are now in the box, because the old advice sent you looking for a silent no-op when what you actually got was an error.

"26 tests across six test files" is seven. Pester prints Running tests from 7 files.

The -Because example showed Should-Be 8 followed by a failure saying it got 9. Get-Planet returns 8 at that point, so that line passes and the printed failure cannot happen. It now says to break it, and prints the message the right way round:

[-] Returns all eight planets 77ms
 Expected [int] 9, because the solar system has eight planets, but got [int] 8.

Dot sourcing does not fail immediately. The dot-source succeeds, and the call fails afterwards on three commands rather than one.

Also added the missing New-Item for the scratch folder, it was the only folder in the tutorial you were told to write into without being told to create it.

Verification

Ran the tutorial from an empty folder on pwsh 7.5.5 with Pester 6.1.0 and reproduced each of the four, then confirmed the replacement text matches the real output. Site builds.

🤖

The -ModuleName warning claimed a mock without -ModuleName never errors. That
holds for a command that also exists outside the module, like Import-Csv, but
the box sits under the Get-PlanetData example, and Get-PlanetData is private, so
Mock cannot find it at all and you get CommandNotFoundException. Split the two
cases.

The CI page said 26 tests across six test files. It is seven, Pester prints
"Running tests from 7 files."

The -Because example showed Should-Be 8 and then a failure saying it got 9. At
that point Get-Planet returns 8, so the line passes and the printed failure
cannot happen. Say to break it, and print the failure the right way round.

Dot-sourcing Get-PlanetDistance.ps1 does not fail immediately. The dot-source
succeeds and the later call fails, once per command it cannot resolve.

Also create the scratch folder before writing the ordering demonstration into
it, it was the only folder in the tutorial without a New-Item step.

Fix #460
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