File Coverage: t/lib/Test/Class/TestGroup.pm

# File Coverage

File: | t/lib/Test/Class/TestGroup.pm
Coverage: | 100.0%

line | stmt | bran | cond | sub | pod | time | code
--- | --- | --- | --- | --- | --- | --- | ---
1 | 1 1 1 |  |  | 1 |  | 0 0 0 | use strict;
2 | 1 1 1 |  |  | 1 |  | 0 0 0 | use warnings;
3 |
4 |  |  |  |  |  |  | package Test::Class::TestGroup;
5 |
6 | 1 1 1 |  |  | 1 |  | 0 0 0 | no warnings 'redefine';
7 |
8 | 1 1 1 |  |  | 1 |  | 0 0 0 | use parent 'Test::Class';
9 |
10 | 1 1 1 |  |  | 1 |  | 0 0 0 | use Test::More;
11 |
12 |  |  |  |  |  |  | sub TestGroup : ATTR(CODE,RAWDATA) {
13 | 6 |  |  | 6 |  | 0 | my ( $class, $symbol, $code_ref, $attr, $args ) = @_;
14 |
15 |  |  |  |  |  |  | # get the test description either from the args, or from the sub routine name; then reset the args to 1 (single test)
16 | 6 2 |  | 100 |  |  | 0 0 | my $test_description = $args || *{$symbol}{NAME};
17 | 6 |  |  |  |  | 0 | $args = 1;
18 |
19 |  |  |  |  |  |  | # wrap the old function in a subtest
20 | 6 6 |  |  |  |  | 0 0 | my $old_func = \&{$symbol};
21 | 6 |  |  |  |  | 0 | *{$symbol} = sub {
22 | 6 |  |  | 6 |  | 0 | my @params = @_;
23 |  |  |  |  |  |  | subtest $test_description => sub {
24 | 6 |  |  | 6 |  | 0 | $old_func->( @params );
25 | 6 |  |  |  |  | 0 | };
26 | 6 |  |  |  |  | 0 | };
27 |
28 |  |  |  |  |  |  | # tell Test::Class to run as a single test
29 | 6 |  |  |  |  | 0 | Test::Class::Test( $class, $symbol, $code_ref, $attr, $args );
30 | 1 1 1 |  |  | 1 |  | 0 0 0 | }
31 |
32 |  |  |  |  |  |  | 1;