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. 😄
This code block reports the correct error.
Assert-VerifiableMocks throw the correct expected error
But if we make a typo in the parameter -Verifiable for the mock
Get-ProcessAssert-VerifiableMocks reports success
I don't know if there is something you can do to fix this. But wanted to report it just in case. 😄