I would like to be able to skip tests if list is empty.
a very simplified example:
No name is -eq to "jens", therefore the $newlist would be empty, and of course the test will fail, but how do i prevent it from going though this test if the list is empty?
context {
BeforeAll{
$List = @(Harry, Hanne, Hans)
$newlist = @()
foreach ($name in $List) {
if (($name -eq "Jens")) {
$name += $newlist
}
}
}
It "The maximum name length is 10 characters" {
$newlist |ForEach-Object {$_.length | Should -BeIn (1..10) -Because "The maximum name length is 10 characters"}
}
}
fail message:
Expected collection @(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) to contain 0, because The maximum name length is 10 characters, but it was not found.