File Coverage

blib/lib/App/Prove/Plugin/TestRail.pm
Criterion Covered Total %
statement 50 52 96.1
branch 2 4 50.0
condition 2 5 40.0
subroutine 6 6 100.0
pod 1 1 100.0
total 61 68 89.7


line stmt bran cond sub pod time code
1             # ABSTRACT: Upload your TAP results to TestRail in realtime
2             # PODNAME: App::Prove::Plugin::TestRail
3              
4             package App::Prove::Plugin::TestRail;
5             $App::Prove::Plugin::TestRail::VERSION = '0.051';
6 1     1   190397 use strict;
  1         14  
  1         32  
7 1     1   6 use warnings;
  1         2  
  1         28  
8 1     1   614 use utf8;
  1         15  
  1         6  
9              
10 1     1   1051 use File::HomeDir qw{my_home};
  1         5791  
  1         70  
11 1     1   461 use TestRail::Utils;
  1         4  
  1         454  
12              
13             sub load {
14 8     8 1 86028 my ( $class, $p ) = @_;
15              
16 8         64 my $app = $p->{app_prove};
17 8         27 my $args = $p->{'args'};
18              
19 8         22 my $params = {};
20              
21             #Only attempt parse if we aren't mocking and the homedir exists
22 8   50     107 my $homedir = my_home() || '.';
23             $params = TestRail::Utils::parseConfig($homedir)
24 8 50 33     713 if -e $homedir && !$ENV{'TESTRAIL_MOCKED'};
25              
26 8         32 my @kvp = ();
27 8         27 my ( $key, $value );
28 8         33 foreach my $arg (@$args) {
29 64         179 @kvp = split( /=/, $arg );
30 64 50       205 if ( scalar(@kvp) < 2 ) {
31 0         0 print
32             "Unrecognized Argument '$arg' to App::Prove::Plugin::Testrail, ignoring\n";
33 0         0 next;
34             }
35 64         107 $key = shift @kvp;
36 64         167 $value = join( '', @kvp );
37 64         217 $params->{$key} = $value;
38             }
39              
40 8         78 $app->harness('Test::Rail::Harness');
41 8         96 $app->merge(1);
42              
43             #XXX I can't figure out for the life of me any other way to pass this data. #YOLO
44 8         136 $ENV{'TESTRAIL_APIURL'} = $params->{apiurl};
45 8         57 $ENV{'TESTRAIL_USER'} = $params->{user};
46 8         37 $ENV{'TESTRAIL_PASS'} = $params->{password};
47 8         35 $ENV{'TESTRAIL_PROJ'} = $params->{project};
48 8         31 $ENV{'TESTRAIL_RUN'} = $params->{run};
49 8         31 $ENV{'TESTRAIL_PLAN'} = $params->{plan};
50 8         33 $ENV{'TESTRAIL_PLAN_ID'} = $params->{plan_id};
51 8         55 $ENV{'TESTRAIL_CONFIGS'} = $params->{configs};
52 8         54 $ENV{'TESTRAIL_VERSION'} = $params->{version};
53 8         41 $ENV{'TESTRAIL_STEPS'} = $params->{step_results};
54 8         36 $ENV{'TESTRAIL_SPAWN'} = $params->{testsuite_id};
55 8         39 $ENV{'TESTRAIL_TESTSUITE'} = $params->{testsuite};
56 8         38 $ENV{'TESTRAIL_SECTIONS'} = $params->{sections};
57 8         51 $ENV{'TESTRAIL_AUTOCLOSE'} = $params->{autoclose};
58 8         50 $ENV{'TESTRAIL_ENCODING'} = $params->{encoding};
59 8         72 $ENV{'TESTRAIL_CGROUP'} = $params->{'configuration_group'};
60 8         44 $ENV{'TESTRAIL_TBAD'} = $params->{'test_bad_status'};
61 8         38 $ENV{'TESTRAIL_MAX_TRIES'} = $params->{'max_tries'};
62 8         87 return $class;
63             }
64              
65             1;
66              
67             __END__