Skip to content

Instantly share code, notes, and snippets.

@markhallen
Created July 18, 2017 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhallen/222b91b55bea4f2722b290b88bbb684c to your computer and use it in GitHub Desktop.
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
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