The ScubaGear testing framework includes Pester PowerShell unit tests for the Defender provider. When these tests are run, they pass, but produce license warnings with the cmdlet Get-Command returns false since it is not connected to any tenant and the reference command is only available after connecting to a licensed tenant. To resolve and ensure maximum tests coverage, Get-Command should be mocked in the Pester tests.
Note that the issue does not cause the test to fail, but it indicates that the test is not properly mocking one of the commands which may limit the tests value.
To reproduce
Steps to reproduce the behavior:
Go to Testing\Unit\PowerShell\Providers\DefenderProvider folder.
Run Invoke-Pester Export-DefenderProvider.Tests.ps1.
Note the WARNINGs generated by the test that say: WARNING: Defender for Office 365 license not available in tenant. Omitting the following commands: Get-AtpPolicyForO365, Get-ATPProtectionPolicyRule.
Expected behavior
The expectation is that the tests run without generating the WARNING, thereby exercising the longest and broadest test path.
🐛 Summary
The ScubaGear testing framework includes Pester PowerShell unit tests for the Defender provider. When these tests are run, they pass, but produce license warnings with the cmdlet
Get-Command
returns false since it is not connected to any tenant and the reference command is only available after connecting to a licensed tenant. To resolve and ensure maximum tests coverage, Get-Command should be mocked in the Pester tests.Note that the issue does not cause the test to fail, but it indicates that the test is not properly mocking one of the commands which may limit the tests value.
To reproduce
Steps to reproduce the behavior:
Testing\Unit\PowerShell\Providers\DefenderProvider
folder.Invoke-Pester Export-DefenderProvider.Tests.ps1
.WARNING: Defender for Office 365 license not available in tenant. Omitting the following commands: Get-AtpPolicyForO365, Get-ATPProtectionPolicyRule.
Expected behavior
The expectation is that the tests run without generating the WARNING, thereby exercising the longest and broadest test path.
Current Test Output