forked from jsf116/Test-Expander
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement subtest skipping, add test plan wherever possible
- Loading branch information
Showing
12 changed files
with
154 additions
and
24 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use strict; | ||
use warnings | ||
FATAL => qw( all ), | ||
NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized ); | ||
|
||
use Test::Expander; | ||
|
||
my $subtestSkipped; | ||
my $mockTest2API = mock 'Test2::API::Context' => ( | ||
override => [ skip => sub { ok( $subtestSkipped, 'subtest skipped' ) } ] | ||
); | ||
|
||
plan( 3 ); | ||
|
||
subtest 'no subtest excluded' => sub { | ||
plan( 2 ); | ||
$subtestSkipped = 0; | ||
lives_ok { $METHOD_REF->( sub { ok( !$subtestSkipped, 'original subtest executed' ) }, 'NAME' ) } 'no changes'; | ||
}; | ||
|
||
subtest 'exclude subtest by number' => sub { | ||
plan( 2 ); | ||
local @ARGV = ( '--exclude_number' => '1/0' ); | ||
Test::Expander::_subtest_selection(); | ||
$subtestSkipped = 1; | ||
lives_ok { $METHOD_REF->( sub { ok( !$subtestSkipped, 'original subtest executed' ) }, 'NAME' ) } 'executed'; | ||
}; | ||
|
||
subtest 'exclude subtest by name' => sub { | ||
plan( 2 ); | ||
local @ARGV = ( '--exclude_name' => '[A-Z]' ); | ||
Test::Expander::_subtest_selection(); | ||
$subtestSkipped = 1; | ||
lives_ok { $METHOD_REF->( sub { ok( !$subtestSkipped, 'original subtest executed' ) }, 'NAME' ) } 'executed'; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use strict; | ||
use warnings | ||
FATAL => qw( all ), | ||
NONFATAL => qw( deprecated exec internal malloc newline once portable redefine recursion uninitialized ); | ||
|
||
use Test2::V0 -target => 'Test::Expander'; | ||
|
||
use Test::Expander::Constants qw( $FMT_INVALID_SUBTEST_NUMBER ); | ||
|
||
plan( 4 ); | ||
|
||
{ | ||
local @ARGV = ( '--exclude_name' => 'valid RegEx' ); | ||
is( Test::Expander::_subtest_selection(), undef, 'exclude subtest by valid RegEx' ); | ||
} | ||
|
||
{ | ||
local @ARGV = ( '--exclude_name' => '[invalid RegEx' ); | ||
is( Test::Expander::_subtest_selection(), undef, 'exclude subtest by invalid RegEx' ); | ||
} | ||
|
||
{ | ||
local @ARGV = ( '--exclude_number' => '1/0/2' ); | ||
is( Test::Expander::_subtest_selection(), undef, 'exclude subtest by valid number' ); | ||
} | ||
|
||
Test2::Tools::Subtest::subtest_streamed 'enforced usage of subtest_streamed for better test coverage' => sub { | ||
plan( 1 ); | ||
local @ARGV = ( '--exclude_number' => '1/0/' ); | ||
my $expected = sprintf( $FMT_INVALID_SUBTEST_NUMBER, '1/0/' ); | ||
like( dies { Test::Expander::_subtest_selection() }, qr/$expected/, 'exclude subtest by invalid number' ); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
## no critic (ProtectPrivateSubs) | ||
|
||
use strict; | ||
use warnings | ||
FATAL => qw( all ), | ||
|