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