Skip to content

Instantly share code, notes, and snippets.

@nohwnd
Last active May 27, 2020 07:52
Show Gist options
  • Save nohwnd/daa4c6526b26497981c2451300d0f672 to your computer and use it in GitHub Desktop.
Save nohwnd/daa4c6526b26497981c2451300d0f672 to your computer and use it in GitHub Desktop.
Passing values from Discovery to Run when generating tests
Describe "a" {
$Sources = @(
[PSCustomObject]@{
Advanced = @{
Enabled = $true
}
}
[PSCustomObject]@{
Advanced = @{
Enabled = $true
}
}
)
foreach ($Source in $Sources) {
It "not happy" {
# $Source is null, because variables are not transfered
# from discovery - this test fails
$Source.Advanced | Should -BeTrue
}
It "happy" -TestCases @{ Source = $Source } {
# $Source is defined from the test case above where
# you saved it during discovery - this test passes
$Source.Advanced | Should -BeTrue
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment