Pester icon indicating copy to clipboard operation
Pester copied to clipboard

Should -Not -Invoke message is a but unclear

Open DarkLite1 opened this issue 4 years ago • 0 comments

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

DarkLite1 avatar Jan 26 '21 15:01 DarkLite1