Harness.pm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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->{'testsuite_id'} = $ENV{'TESTRAIL_SPAWN'};
  44. $args->{'testsuite'} = $ENV{'TESTRAIL_TESTSUITE'};
  45. @sections = split(/:/,$ENV{'TESTRAIL_SECTIONS'}) if $ENV{'TESTRAIL_SECTIONS'};
  46. $args->{'sections'} = \@sections if scalar(@sections);
  47. $args->{'autoclose'} = $ENV{'TESTRAIL_AUTOCLOSE'};
  48. #for Testability of plugin
  49. if ($ENV{'TESTRAIL_MOCKED'}) {
  50. use lib 't/lib'; #Unit tests will always run from the main dir during make test
  51. require 't/lib/Test/LWP/UserAgent/TestRailMock.pm' unless defined $Test::LWP::UserAgent::TestRailMock::mockObject; ## no critic
  52. $args->{'debug'} = 1;
  53. $args->{'browser'} = $Test::LWP::UserAgent::TestRailMock::mockObject;
  54. }
  55. $self->SUPER::_make_callback( 'parser_args', $args, $job->as_array_ref );
  56. my $parser = $self->SUPER::_construct( $self->SUPER::parser_class, $args );
  57. $self->SUPER::_make_callback( 'made_parser', $parser, $job->as_array_ref );
  58. my $session = $self->SUPER::formatter->open_test( $job->description, $parser );
  59. return ( $parser, $session );
  60. }
  61. 1;
  62. __END__
  63. =head1 SEE ALSO
  64. L<TestRail::API>
  65. L<Test::Rail::Parser>
  66. L<App::Prove>
  67. =head1 SPECIAL THANKS
  68. Thanks to cPanel Inc, for graciously funding the creation of this module.