Skip to content

Say what went wrong when a module test is written the wrong way #3000

Description

@nohwnd

The mistakes listed in #2996 all fail the same way. You get $null, or a mock that did not apply, and nothing tells you which of the rules you broke. These are error message changes, no new API and no design decision:

  • Mock Get-Internal where the command is not visible from the test scope but does exist in a loaded module. Say so, name the module, suggest -ModuleName.
  • a variable is $null inside InModuleScope while a variable of the same name exists in the enclosing scope. Mention -Parameters.
  • -ForEach is null or empty and the value came from a BeforeAll variable. Point at BeforeDiscovery. FailOnNullOrEmptyForEach already gives us the hook, only the message needs to know more.
  • Pester 3 is loaded and the file uses v5 syntax. Say that, instead of failing on BeforeAll not being recognized.

None of these need anyone to agree on a design first, and I think they would remove more questions than anything else on the list.

Part of #2996.

🤖

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions