Harness.pm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # ABSTRACT: TestRail testing harness
  2. # PODNAME: Test::Rail::Harness
  3. package Test::Rail::Harness;
  4. use strict;
  5. use warnings;
  6. use parent qw/TAP::Harness/;
  7. =head1 DESCRIPTION
  8. Connective tissue for App::Prove::Plugin::TestRail. Nothing to see here...
  9. Subclass of TAP::Harness.
  10. =head1 OVERRIDDEN METHODS
  11. =head2 new
  12. Tells the harness to use Test::Rail::Parser and passes off to the parent.
  13. =cut
  14. # inject parser_class as Test::Rail::Parser.
  15. sub new {
  16. my $class = shift;
  17. my $arg_for = shift;
  18. $arg_for->{parser_class} = 'Test::Rail::Parser';
  19. my $self = $class->SUPER::new($arg_for);
  20. return $self;
  21. }
  22. =head2 make_parser
  23. Picks the arguments passed to App::Prove::Plugin::TestRail out of $ENV and shuttles them to it's constructor.
  24. =cut
  25. sub make_parser {
  26. my ($self, $job) = @_;
  27. my $args = $self->SUPER::_get_parser_args($job);
  28. my @configs = ();
  29. my @sections = ();
  30. #XXX again, don't see any way of getting this downrange to my parser :(
  31. $args->{'apiurl'} = $ENV{'TESTRAIL_APIURL'};
  32. $args->{'user'} = $ENV{'TESTRAIL_USER'};
  33. $args->{'pass'} = $ENV{'TESTRAIL_PASS'};
  34. $args->{'encoding'} = $ENV{'TESTRAIL_ENCODING'};
  35. $args->{'project'} = $ENV{'TESTRAIL_PROJ'};
  36. $args->{'run'} = $ENV{'TESTRAIL_RUN'};
  37. $args->{'plan'} = $ENV{'TESTRAIL_PLAN'};
  38. $args->{'plan_id'} = $ENV{'TESTRAIL_PLAN_ID'};
  39. @configs = split(/:/,$ENV{'TESTRAIL_CONFIGS'}) if $ENV{'TESTRAIL_CONFIGS'};
  40. $args->{'configs'} = \@configs if scalar(@configs);
  41. $args->{'result_options'} = {'version' => $ENV{'TESTRAIL_VERSION'}} if $ENV{'TESTRAIL_VERSION'};
  42. $args->{'step_results'} = $ENV{'TESTRAIL_STEPS'};
  43. $args->{'testsuite_id'} = $ENV{'TESTRAIL_SPAWN'};
  44. $args->{'testsuite'} = $ENV{'TESTRAIL_TESTSUITE'};
  45. $args->{'config_group'} = $ENV{'TESTRAIL_CGROUP'};
  46. $args->{'test_bad_status'} = $ENV{'TESTRAIL_TBAD'};
  47. $args->{'max_tries'} = $ENV{'TESTRAIL_MAX_TRIES'};
  48. @sections = split(/:/,$ENV{'TESTRAIL_SECTIONS'}) if $ENV{'TESTRAIL_SECTIONS'};
  49. $args->{'sections'} = \@sections if scalar(@sections);
  50. $args->{'autoclose'} = $ENV{'TESTRAIL_AUTOCLOSE'};
  51. #for Testability of plugin XXX probably some of the last remaining grotiness
  52. if ($ENV{'TESTRAIL_MOCKED'}) {
  53. use lib 't/lib'; #Unit tests will always run from the main dir during make test
  54. if (!defined $Test::LWP::UserAgent::TestRailMock::mockObject) {
  55. require 't/lib/Test/LWP/UserAgent/TestRailMock.pm'; ## no critic
  56. }
  57. $args->{'debug'} = 1;
  58. $args->{'browser'} = $Test::LWP::UserAgent::TestRailMock::mockObject;
  59. }
  60. $self->SUPER::_make_callback( 'parser_args', $args, $job->as_array_ref );
  61. my $parser = $self->SUPER::_construct( $self->SUPER::parser_class, $args );
  62. $self->SUPER::_make_callback( 'made_parser', $parser, $job->as_array_ref );
  63. my $session = $self->SUPER::formatter->open_test( $job->description, $parser );
  64. return ( $parser, $session );
  65. }
  66. 1;
  67. __END__
  68. =head1 SEE ALSO
  69. L<TestRail::API>
  70. L<Test::Rail::Parser>
  71. L<App::Prove>
  72. =head1 SPECIAL THANKS
  73. Thanks to cPanel Inc, for graciously funding the creation of this module.