Hi,
I am missing something, or something is broken, but I can only seem to get my tests to work if I duplicate the params in the beforeAll within the beforeDiscovery.
From the documentation I read it as anything in the beforeAll should be passed to every test within the describe block.
So why do I need to do this?
BeforeAll {
$r = Get-Content .\DevTest.Parameters.json | ConvertFrom-Json -AsHashtable
$expectedvNets = $r.virtualNetworks.Values
$deployedvNets = (Get-AzVirtualNetwork).Name
$expectedResourceGroups = $R.resourceGroups.Values
$deployedResourceGroups = (get-AzResourceGroup).ResourceGroupName
}
Describe 'Azure Infrastructure Testing' {
BeforeDiscovery {
$r = Get-Content .\DevTest.Parameters.json | ConvertFrom-Json -AsHashtable
$expectedvNets = $r.virtualNetworks.Values
$deployedvNets = (Get-AzVirtualNetwork).Name
$expectedResourceGroups = $R.resourceGroups.Values
$deployedResourceGroups = (get-AzResourceGroup).ResourceGroupName
}
Context 'Checking Deployed components align with designs' {
It "Checking resourceGroup exists" -Foreach $expectedResourceGroups {
$deployedResourceGroups | Should -Contain $_
}
It "Checking Virtual network exists" -Foreach $expectedvNets {
$deployedvNets | Should -Contain $_
}
}
}
If I remove the before discovery, all tests fail.
Where am I going wrong?
Thanks