bin/testrail-bulk-mark-results

filter: Statementstmt 95.9% 47 / 49 Branchbran 60.0% 6 / 10 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 9 / 9 Podpod n/a totaltotal 88.7% 63 / 71 CC 6 SCAR 11.9
CC
6
Cov
89%
run
6.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.3
« blib/lib/App/Prove/Plugin/TestRail.pm ↑ Summary bin/testrail-tests »
1 #!/usr/bin/perl
2 # ABSTRACT: Bulk mark entire runs/plans (or groups of tests therein) as the provided status.
3 # PODNAME: TestRail::Bin::BulkMarkResults
4  
5 package TestRail::Bin::BulkMarkResults;
6 1 $TestRail::Bin::BulkMarkResults::VERSION = '0.052';
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use TestRail::API;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use TestRail::Utils;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use TestRail::Utils::Results;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 ▶use Getopt::Long qw{GetOptionsFromArray};
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 Getopt::Long::Configure('pass_through');
17  
18 2 ▶use File::HomeDir qw{my_home};
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 ▶if ( !caller() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (caller()) 1 0 1
21 1 my ( $out, $code ) = run( 'args' => \@ARGV );
22 1 print $out;
23 1 exit $code;
24 }
25  
26 3 ▶sub run {
Subroutine run: called CC=6 SCAR=18.4
27 3 my %params = @_;
28 3 my $opts = {};
29  
30 # Parse config file
31 3 ▶ my $homedir = my_home() || '.';
Condition50%1/2
my_home() || '.'
l!l
30
MC/DC0%0/1
my_home() || '.'
my_home()
Truth table50%1/2
A
A= my_home()
Aresult
11
00
32 3 ▶ if ( -e $homedir . '/.testrailrc' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $homedir . '/.testrailrc') 0 3 3
33 0 $opts = TestRail::Utils::parseConfig($homedir);
34 }
35  
36 # Override configuration with switches
37 GetOptionsFromArray(
38 $params{'args'},
39 'apiurl=s' => \$opts->{'apiurl'},
40 'password=s' => \$opts->{'password'},
41 'user=s' => \$opts->{'user'},
42 'status=s@' => \$opts->{'statuses'},
43 'j|project=s' => \$opts->{'project'},
44 'p|plan=s' => \$opts->{'plan'},
45 'r|run=s' => \$opts->{'run'},
46 'c|config=s@' => \$opts->{'configs'},
47 'a|assignedto=s@' => \$opts->{'users'},
48 'e|encoding=s' => \$opts->{'encoding'},
49 3 'h|help' => \$opts->{'help'},
50 );
51  
52 3 ▶ if ( $opts->{help} ) { return ( '', TestRail::Utils::help() ); }
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"help"}) 2 1 3
53  
54 1 $opts->{'browser'} = $params{'browser'};
55  
56 1 my $status = $params{'args'}->[0];
57 1 my $reason = $params{'args'}->[1];
58  
59 1 ▶ die("No status to set provided.") unless $status;
Branch: 1 branch
BranchTrueFalseTotal
unless $status 0 1 1
60 1 TestRail::Utils::interrogateUser( $opts,
61 qw{apiurl user password project run} );
62  
63 1 my $tr = TestRail::Utils::getHandle($opts);
64  
65 1 $opts->{'set_status_to'} = $status;
66 1 $opts->{'reason'} = $reason;
67 1 my $results = TestRail::Utils::Results::bulkMarkResults( $opts, $tr );
68  
69 return (
70 1 ▶ "Successfully set the status of "
Branch: 1 branch
BranchTrueFalseTotal
if $results 1 0 1
71 . scalar(@$results)
72 . " cases to $status.\n",
73 0
74 ) if $results;
75 0 return ( "Could find no cases to set results for.\n", 255 );
76 }
77  
78 1;
79  
80 =pod
81  
82 =encoding UTF-8
83  
84 =head1 NAME
85  
86 TestRail::Bin::BulkMarkResults - Bulk mark entire runs/plans (or groups of tests therein) as the provided status.
87  
88 =head1 VERSION
89  
90 version 0.052
91  
92 =head1 DESCRIPTION
93  
94 Sometimes it is useful to mark entire runs of tests when, for example, a prerequisite test in a sequence invalidates all further tests.
95 For example, if a binary produced for test fails to run at all, more detailed testing will be impossible;
96 it would save time to just mark everything as blocked.
97  
98 Can be used as the modulino TestRail::Bin::BulkMarkResults.
99 Has a single 'run' function which accepts a hash with the 'args' parameter being the array of arguments.
100  
101 =head1 USAGE
102  
103 testrail-bulk-mark-results [OPTIONS] status [reason]
104  
105 require `which testrail-bulk-mark-results`;
106 TestRail::Bin::BulkMarkResults::run('args' => \@args);
107  
108 =head1 PARAMETERS:
109  
110 =head2 MANDATORY PARAMETERS
111  
112 =over 4
113  
114 --apiurl : full URL to get to TestRail index document
115  
116 --password : Your TestRail Password, or a valid API key (TestRail 4.2 and above).
117  
118 --user : Your TestRail User Name.
119  
120 -j --project : desired project name.
121  
122 -r --run : desired run name.
123  
124 =back
125  
126 All mandatory options not passed with the above switches, or in your ~/.testrailrc will be prompted for.
127  
128 =head2 SEMI-OPTIONAL PARAMETERS
129  
130 =over 4
131  
132 -p --plan : desired plan name. Required if the run passed is a child of a plan.
133  
134 -e --encoding : Character encoding of arguments. Defaults to UTF-8. See L<Encode::Supported> for supported encodings.
135  
136 =back
137  
138 =head2 OPTIONAL PARAMETERS
139  
140 =over 4
141  
142 -c --config : configuration name to filter plans in run. Can be passed multiple times.
143  
144 -s --status : only mark tests already marked as [status] in testrail. Can be passed multiple times.
145  
146 -a --assignedto : only mark tests assigned to user. Can be passed multiple times.
147  
148 =back
149  
150 =head1 CONFIGURATION FILE
151  
152 In your \$HOME, (or the current directory, if your system has no concept of a home directory) put a file called .testrailrc with key=value syntax separated by newlines.
153 Valid Keys are the same as documented by L<App::Prove::Plugin::TestRail>.
154 All options specified thereby are overridden by passing the command-line switches above.
155  
156 =head1 MISCELLANEOUS OPTIONS:
157  
158 =over 4
159  
160 --help : show this output
161  
162 =back
163  
164 =head1 SPECIAL THANKS
165  
166 Thanks to cPanel Inc, for graciously funding the creation of this distribution.
167  
168 =head1 AUTHOR
169  
170 George S. Baugh <teodesian@cpan.org>
171  
172 =head1 SOURCE
173  
174 The development version is on github at L<https://github.com/teodesian/TestRail-Perl>
175 and may be cloned from L<git://github.com/teodesian/TestRail-Perl.git>
176  
177 =head1 COPYRIGHT AND LICENSE
178  
179 This software is copyright (c) 2022 by George S. Baugh.
180  
181 This is free software; you can redistribute it and/or modify it under
182 the same terms as the Perl 5 programming language system itself.
183  
184 =cut
185  
186 __END__
« blib/lib/App/Prove/Plugin/TestRail.pm ↑ Summary bin/testrail-tests »