Skip to content

Should -Not -Invoke message is a but unclear #1832

Open
@DarkLite1

Description

@DarkLite1

General summary of the issue

A different message is displayed for Should -Not -Invoke and Should -Invoke -Time 0 -Exactly. The message Expected Test-Me not to be called exactly 1 times is a but unclear to me.

Describe your environment

Pester version : 5.1.1 C:\Program Files\WindowsPowerShell\Modules\Pester\5.1.1\Pester.psm1
PowerShell version : 5.1.14393.3866
OS version : Microsoft Windows NT 10.0.14393.0

Steps to reproduce

Describe 'test the Pester error message' {
    BeforeAll {
        Function Test-Me { 1 }
        Mock Test-Me
        Test-Me
    }
    It 'should fail' {
        Should -Not -Invoke test-Me -Scope Describe
        # Expected Test-Me not to be called exactly 1 times
    }
    It 'should fail' {
        Should -Times 0 -Exactly -Invoke test-Me -Scope Describe
        # Expected Test-Me to be called 0 times exactly but was called 1 times
    }
}

Expected Behavior

For Should -Not -Invoke test-Me -Scope Describe it might be better to say:

Expected Test-Me not to be called but it was called 1 time

Current Behavior

See comments above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions