Skip
Skip on everything​
-Skip
is now available on Describe and Context. This allows you to skip all the tests in that block and every child block.
Describe "describe1" {
Context "with one skipped test" {
It "test 1" -Skip {
1 | Should -Be 2
}
It "test 2" {
1 | Should -Be 1
}
}
Describe "that is skipped" -Skip {
It "test 3" {
1 | Should -Be 2
}
}
Context "that is skipped and has skipped test" -Skip {
It "test 3" -Skip {
1 | Should -Be 2
}
It "test 3" {
1 | Should -Be 2
}
}
}
Starting test discovery in 1 files.
Found 5 tests. 117ms
Test discovery finished. 418ms
Describing describe1
Context with one skipped test
[!] test 1, is skipped 18ms (0ms|18ms)
[+] test 2 52ms (29ms|22ms)
Describing that is skipped
[!] test 3, is skipped 12ms (0ms|12ms)
Context that is skipped and has skipped test
[!] test 3, is skipped 10ms (0ms|10ms)
[!] test 3, is skipped 10ms (0ms|10ms)
Tests completed in 1.03s
Tests Passed: 1, Failed: 0, Skipped: 4, Total: 5, NotRun: 0
warning
Pending is translated to skipped, Inconclusive does not exist anymore.
Conditional skip​
Evaluation of the skip-parameter is done as part of the Discovery-phase. This means you can also dynamically skip tests based on values available in that phase. Either as logic done in BeforeDiscovery or based on values passed into a parametrized test.
$sb = {
param($SkipFirst)
Describe 'My Describe Block' {
BeforeDiscovery {
$skipSecond = 1
}
It 'First Test' -Skip:$SkipFirst {
1 | Should -Be 1
}
It 'Second Test' -Skip:($skipSecond -eq 1) {
1 | Should -Be 1
}
It 'Third Test' {
1 | Should -Be 1
}
}
}
$container = New-PesterContainer -ScriptBlock $sb -Data @{ SkipFirst = $true }
$configuration = New-PesterConfiguration
$configuration.Run.Container = $container
$configuration.Output.Verbosity = 'Detailed'
Invoke-Pester -Configuration $configuration
Starting discovery in 1 files.
Discovering in
param($SkipFirst)
Describe 'My Describe Block' {
BeforeDiscovery {
$skipSecond = 1
}
It 'First Test' -Skip:$SkipFirst {
1 | Should -Be 1
}
It 'Second Test' -Skip:($skipSecond -eq 1) {
1 | Should -Be 1
}
It 'Third Test' {
1 | Should -Be 1
}
}
.
Found 3 tests. 37ms
Discovery finished in 97ms.
Running tests.
Describing My Describe Block
[!] First Test 3ms (0ms|3ms)
[!] Second Test 2ms (0ms|2ms)
[+] Third Test 18ms (16ms|3ms)
Tests completed in 206ms
Tests Passed: 1, Failed: 0, Skipped: 2 NotRun: 0