Results.pm 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # PODNAME: TestRail::Utils::Results
  2. # ABSTRACT: Perform batch operations on test results, and analyze the same.
  3. package TestRail::Utils::Results;
  4. use strict;
  5. use warnings;
  6. use Carp qw{confess cluck};
  7. use Scalar::Util qw{blessed};
  8. use TestRail::Utils::Find;
  9. =head1 FUNCTIONS
  10. =head2 bulkMarkResults(options,TestRail::API)
  11. Primary routine of testrail-bulk-mark-results.
  12. Takes same options as the aforementioned binary as a HASHREF, with the following exceptions:
  13. =over 4
  14. =item C<users> ARRAYREF (optional) - corresponds to --assignedto options passed
  15. =item C<statuses> ARRAYREF (optional) - corresponds to --status options passed
  16. =item C<set_status_to> STRING - Status to bulk-set cases to (ARGV[0])
  17. =item C<reason> STRING (optional) - Reason to do said bulk-set, recorded as result comment (ARGV[1])
  18. =back
  19. =cut;
  20. sub bulkMarkResults {
  21. my ($opts,$tr) = @_;
  22. confess("TestRail handle must be provided as argument 2") unless blessed($tr) eq 'TestRail::API';
  23. my ($cases,$run) = TestRail::Utils::Find::getTests($opts,$tr);
  24. die "No cases in TestRail to mark!\n" unless $cases;
  25. my ($status_id) = $tr->statusNamesToIds($opts->{'set_status_to'});
  26. @$cases = map {
  27. {
  28. 'test_id' => $_->{'id'},
  29. 'status_id' => $status_id,
  30. 'comment' => $opts->{'reason'},
  31. 'version' => $opts->{'version'}
  32. }
  33. } @$cases;
  34. return $tr->bulkAddResults($run->{'id'},$cases);
  35. }
  36. 1;