Harness.pm 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. @configs = split(/:/,$ENV{'TESTRAIL_CONFIGS'}) if $ENV{'TESTRAIL_CONFIGS'};
  39. $args->{'configs'} = \@configs if scalar(@configs);
  40. $args->{'result_options'} = {'version' => $ENV{'TESTRAIL_VERSION'}} if $ENV{'TESTRAIL_VERSION'};
  41. $args->{'case_per_ok'} = $ENV{'TESTRAIL_CASEOK'};
  42. $args->{'step_results'} = $ENV{'TESTRAIL_STEPS'};
  43. $args->{'spawn'} = $ENV{'TESTRAIL_SPAWN'};
  44. @sections = split(/:/,$ENV{'TESTRAIL_SECTIONS'}) if $ENV{'TESTRAIL_SECTIONS'};
  45. $args->{'sections'} = \@sections if scalar(@sections);
  46. $args->{'autoclose'} = $ENV{'TESTRAIL_AUTOCLOSE'};
  47. #for Testability of plugin
  48. if ($ENV{'TESTRAIL_MOCKED'}) {
  49. require Test::LWP::UserAgent::TestRailMock;
  50. $args->{'debug'} = 1;
  51. $args->{'browser'} = $Test::LWP::UserAgent::TestRailMock::mockObject;
  52. }
  53. $self->SUPER::_make_callback( 'parser_args', $args, $job->as_array_ref );
  54. my $parser = $self->SUPER::_construct( $self->SUPER::parser_class, $args );
  55. $self->SUPER::_make_callback( 'made_parser', $parser, $job->as_array_ref );
  56. my $session = $self->SUPER::formatter->open_test( $job->description, $parser );
  57. return ( $parser, $session );
  58. }
  59. 1;
  60. __END__
  61. =head1 SEE ALSO
  62. L<TestRail::API>
  63. L<Test::Rail::Parser>
  64. L<App::Prove>
  65. =head1 SPECIAL THANKS
  66. Thanks to cPanel Inc, for graciously funding the creation of this module.