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