| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #!/usr/bin/env perl
- # ABSTRACT: Bulk mark entire runs/plans (or groups of tests therein) as the provided status.
- # PODNAME: testrail-bulk-mark-results
- =head1 USAGE
- testrail-bulk-mark-results [OPTIONS] status [reason]
- =head1 DESCRIPTION
- Sometimes it is useful to mark entire runs of tests when, for example, a prerequisite test in a sequence invalidates all further tests.
- For example, if a binary produced for test fails to run at all, more detailed testing will be impossible;
- it would save time to just mark everything as blocked.
- =head1 PARAMETERS:
- =head2 MANDATORY PARAMETERS
- =over 4
- --apiurl : full URL to get to TestRail index document
- --password : Your TestRail Password, or a valid API key (TestRail 4.2 and above).
- --user : Your TestRail User Name.
- -j --project : desired project name.
- -r --run : desired run name.
- =back
- All mandatory options not passed with the above switches, or in your ~/.testrailrc will be prompted for.
- =head2 SEMI-OPTIONAL PARAMETERS
- =over 4
- -p --plan : desired plan name. Required if the run passed is a child of a plan.
- -e --encoding : Character encoding of arguments. Defaults to UTF-8. See L<Encode::Supported> for supported encodings.
- =back
- =head2 OPTIONAL PARAMETERS
- =over 4
- -c --config : configuration name to filter plans in run. Can be passed multiple times.
- -s --status : only mark tests already marked as [status] in testrail. Can be passed multiple times.
- -a --assignedto : only mark tests assigned to user. Can be passed multiple times.
- =back
- =head1 CONFIGURATION FILE
- 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.
- Valid Keys are the same as documented by L<App::Prove::Plugin::TestRail>.
- All options specified thereby are overridden by passing the command-line switches above.
- =head1 MISCELLANEOUS OPTIONS:
- =over 4
- --help : show this output
- =back
- =cut
- use strict;
- use warnings;
- use utf8;
- use TestRail::API;
- use TestRail::Utils;
- use TestRail::Utils::Results;
- use Getopt::Long;
- Getopt::Long::Configure('pass_through');
- use File::HomeDir qw{my_home};
- my $opts = {};
- # Parse config file
- my $homedir = my_home() || '.';
- if (-e $homedir . '/.testrailrc') {
- $opts = TestRail::Utils::parseConfig($homedir);
- }
- # Override configuration with switches
- GetOptions(
- 'apiurl=s' => \$opts->{'apiurl'},
- 'password=s' => \$opts->{'password'},
- 'user=s' => \$opts->{'user'},
- 'assignedto=s@' => \$opts->{'users'},
- 'status=s@' => \$opts->{'statuses'},
- 'j|project=s' => \$opts->{'project'},
- 'p|plan=s' => \$opts->{'plan'},
- 'r|run=s' => \$opts->{'run'},
- 'c|config=s@' => \$opts->{'configs'},
- 'a|assignedto=s@' => \$opts->{'users'},
- 'e|encoding=s' => \$opts->{'encoding'},
- 'h|help' => \$opts->{'help'},
- 'mock' => \$opts->{'mock'}
- );
- if ($opts->{help}) { TestRail::Utils::help(); }
- my $status = $ARGV[0];
- my $reason = $ARGV[1];
- die("No status to set provided.") unless $status;
- TestRail::Utils::interrogateUser($opts,qw{apiurl user password project run});
- my $tr = TestRail::Utils::getHandle($opts);
- $opts->{'set_status_to'} = $status;
- $opts->{'reason'} = $reason;
- my $results = TestRail::Utils::Results::bulkMarkResults($opts,$tr);
- print "Successfully set the status of ".scalar(@$results)." cases to $status.\n" if $results;
- exit 0;
- __END__
- L<TestRail::API>
- L<File::HomeDir> for the finding of .testrailrc
- =head1 SPECIAL THANKS
- Thanks to cPanel Inc, for graciously funding the creation of this distribution.
|