File Coverage

blib/lib/Test/Rail/Harness.pm
Criterion Covered Total %
statement 51 51 100.0
branch 13 14 92.8
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 72 73 98.6


line stmt bran cond sub pod time code
1             # ABSTRACT: TestRail testing harness
2             # PODNAME: Test::Rail::Harness
3             package Test::Rail::Harness;
4             $Test::Rail::Harness::VERSION = '0.051';
5 1     1   728 use strict;
  1         3  
  1         33  
6 1     1   6 use warnings;
  1         2  
  1         35  
7              
8 1     1   5 use parent qw/TAP::Harness/;
  1         3  
  1         7  
9              
10             # inject parser_class as Test::Rail::Parser.
11             sub new {
12 8     8 1 9106 my $class = shift;
13 8         22 my $arg_for = shift;
14 8         33 $arg_for->{parser_class} = 'Test::Rail::Parser';
15 8         38 my $self = $class->SUPER::new($arg_for);
16 8         13810 return $self;
17             }
18              
19             sub make_parser {
20 9     9 1 21831 my ( $self, $job ) = @_;
21 9         55 my $args = $self->SUPER::_get_parser_args($job);
22 9         966 my @configs = ();
23 9         21 my @sections = ();
24              
25             #XXX again, don't see any way of getting this downrange to my parser :(
26 9         36 $args->{'apiurl'} = $ENV{'TESTRAIL_APIURL'};
27 9         28 $args->{'user'} = $ENV{'TESTRAIL_USER'};
28 9         39 $args->{'pass'} = $ENV{'TESTRAIL_PASS'};
29 9         62 $args->{'encoding'} = $ENV{'TESTRAIL_ENCODING'};
30 9         25 $args->{'project'} = $ENV{'TESTRAIL_PROJ'};
31 9         29 $args->{'run'} = $ENV{'TESTRAIL_RUN'};
32 9         30 $args->{'plan'} = $ENV{'TESTRAIL_PLAN'};
33 9         25 $args->{'plan_id'} = $ENV{'TESTRAIL_PLAN_ID'};
34             @configs = split( /:/, $ENV{'TESTRAIL_CONFIGS'} )
35 9 100       54 if $ENV{'TESTRAIL_CONFIGS'};
36 9 100       41 $args->{'configs'} = \@configs if scalar(@configs);
37             $args->{'result_options'} = { 'version' => $ENV{'TESTRAIL_VERSION'} }
38 9 100       48 if $ENV{'TESTRAIL_VERSION'};
39 9         49 $args->{'step_results'} = $ENV{'TESTRAIL_STEPS'};
40 9         47 $args->{'testsuite_id'} = $ENV{'TESTRAIL_SPAWN'};
41 9         26 $args->{'testsuite'} = $ENV{'TESTRAIL_TESTSUITE'};
42 9         45 $args->{'config_group'} = $ENV{'TESTRAIL_CGROUP'};
43 9         23 $args->{'test_bad_status'} = $ENV{'TESTRAIL_TBAD'};
44 9         23 $args->{'max_tries'} = $ENV{'TESTRAIL_MAX_TRIES'};
45              
46             @sections = split( /:/, $ENV{'TESTRAIL_SECTIONS'} )
47 9 100       40 if $ENV{'TESTRAIL_SECTIONS'};
48 9 100       31 $args->{'sections'} = \@sections if scalar(@sections);
49 9         22 $args->{'autoclose'} = $ENV{'TESTRAIL_AUTOCLOSE'};
50              
51             #for Testability of plugin XXX probably some of the last remaining grotiness
52 9 50       25 if ( $ENV{'TESTRAIL_MOCKED'} ) {
53 1         8 use lib 't/lib'
54 1     1   4991 ; #Unit tests will always run from the main dir during make test
  1         10  
55 9 100       29 if ( !defined $Test::LWP::UserAgent::TestRailMock::mockObject ) {
56 1         2392 require 't/lib/Test/LWP/UserAgent/TestRailMock.pm'; ## no critic
57             }
58 9         70246 $args->{'debug'} = 1;
59 9         26 $args->{'browser'} = $Test::LWP::UserAgent::TestRailMock::mockObject;
60             }
61              
62 9         52 $self->SUPER::_make_callback( 'parser_args', $args, $job->as_array_ref );
63 9         386 my $parser = $self->SUPER::_construct( $self->SUPER::parser_class, $args );
64              
65 9         230 $self->SUPER::_make_callback( 'made_parser', $parser, $job->as_array_ref );
66 9         777 my $session =
67             $self->SUPER::formatter->open_test( $job->description, $parser );
68              
69 9         3445 return ( $parser, $session );
70             }
71              
72             1;
73              
74             __END__