Skip to content

Assert-VerifiableMocks silently does not report anything if 'Verifiable' is spelled wrong on one mock #781

@johlju

Description

@johlju

This code block reports the correct error.

Describe 'Tests' {
    Mock Get-Service -MockWith { return 'wuausrv' } -Verifiable
    Mock Get-Process -MockWith { return 'setup' } -Verifiable

    Context 'When something happens' {
        It 'Should return correct values' {
            Get-Service | Should Be 'wuausrv'
            #Get-Process | Should Be 'setup'
        }
    }

    Assert-VerifiableMocks
}

Assert-VerifiableMocks throw the correct expected error

Describing Tests

  Context When something happens
    [+] Should return correct values 124ms
  [-] Error occurred in Describe block 27ms

     Expected Get-Process to be called with $True
    At C:\Program Files\WindowsPowerShell\Modules\Pester\4.0.3\Functions\Mock.ps1:428 char:9

But if we make a typo in the parameter -Verifiable for the mock Get-Process

Describe 'Tests' {
    Mock Get-Service -MockWith { return 'wuausrv' } -Verifiable
    Mock Get-Process -MockWith { return 'setup' } -Verfiable

    Context 'When something happens' {
        It 'Should return correct values' {
            Get-Service | Should Be 'wuausrv'
            #Get-Process | Should Be 'setup'
        }
    }

    Assert-VerifiableMocks
}

Assert-VerifiableMocks reports success

Describing Tests

  Context When something happens
    [+] Should return correct values 76ms

I don't know if there is something you can do to fix this. But wanted to report it just in case. 😄

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions