Created
July 18, 2017 15:09
-
-
Save markhallen/222b91b55bea4f2722b290b88bbb684c to your computer and use it in GitHub Desktop.
Loop through test cases in pester
https://github.com/pester/Pester/issues/179
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
function Add-Numbers($a, $b) { | |
return $a + $b | |
} | |
Describe "Add-Numbers" { | |
$testCases = @( | |
@{ a = 2; b = 3; expectedResult = 5 } | |
@{ a = -2; b = -2; expectedResult = -4 } | |
@{ a = -2; b = 2; expectedResult = 0 } | |
@{ a = 'two'; b = 'three'; expectedResult = 'twothree' } | |
) | |
It 'Correctly adds <a> and <b> to get <expectedResult>' -TestCases $testCases { | |
param ($a, $b, $expectedResult) | |
$sum = Add-Numbers $a $b | |
$sum | Should Be $expectedResult | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment