Last active
May 27, 2020 07:52
-
-
Save nohwnd/daa4c6526b26497981c2451300d0f672 to your computer and use it in GitHub Desktop.
Passing values from Discovery to Run when generating tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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