This repository was archived by the owner on Feb 24, 2021. It is now read-only.
This repository was archived by the owner on Feb 24, 2021. It is now read-only.
Stupid mock assertions in tests #472
Open
Description
There is a lot of stupid assertions in tests which test implementation details instead of behavior. It doesn't add any value but only makes refactoring harder and bloats the tests code (for example MSFT_xWebsiteTests.ps1
has almost 4k lines of code, it's really hard to manage that)
Example:
It 'Should call all the mocks' {
Assert-MockCalled -CommandName Add-WebConfiguration -Exactly 1
Assert-MockCalled -CommandName Confirm-UniqueBinding -Exactly 1
Assert-MockCalled -CommandName Confirm-UniqueServiceAutoStartProviders -Exactly 1
Assert-MockCalled -CommandName Test-AuthenticationEnabled -Exactly 4
Assert-MockCalled -CommandName Test-WebsiteBinding -Exactly 1
Assert-MockCalled -CommandName Update-WebsiteBinding -Exactly 1
Assert-MockCalled -CommandName Update-DefaultPage -Exactly 1
Assert-MockCalled -CommandName Set-Authentication -Exactly 4
Assert-MockCalled -CommandName Get-Item -Exactly 3
Assert-MockCalled -CommandName Set-Item -Exactly 3
Assert-MockCalled -CommandName Set-ItemProperty -Exactly 9
Assert-MockCalled -CommandName Start-Website -Exactly 1
Assert-MockCalled -CommandName Set-WebConfigurationProperty -Exactly 2
Assert-MockCalled -CommandName Test-LogCustomField -Exactly 1
}
I would like to propose to delete all that assertions add mention it as a bad practice in the Contribution guideline.