App-Prove-Plugin-Testrail.t 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use FindBin;
  5. use lib "$FindBin::Bin/lib";
  6. use Test::More 'tests' => 8;
  7. use Test::Fatal;
  8. use Capture::Tiny qw{capture};
  9. use App::Prove;
  10. use App::Prove::Plugin::TestRail;
  11. #I'm the secret squirrel
  12. $ENV{'TESTRAIL_MOCKED'} = 1;
  13. #Test the same sort of data as would come from the Test::Rail::Parser case
  14. my $prove = App::Prove->new();
  15. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite,version=0.014",'t/fake.test');
  16. is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions");
  17. #Check that plan, configs and version also make it through
  18. $prove = App::Prove->new();
  19. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=Executing the great plan,version=0.014,plan=GosPlan,configs=testConfig",'t/fake.test');
  20. is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions works with configs/plans");
  21. #Check that spawn options make it through
  22. $prove = App::Prove->new();
  23. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite2,version=0.014,testsuite_id=9",'t/skipall.test');
  24. is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions works with configs/plans");
  25. $prove = App::Prove->new();
  26. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=bogoPlan,run=bogoRun,version=0.014,testsuite=HAMBURGER-IZE HUMANITY",'t/skipall.test');
  27. is (exception { capture { $prove->run() } },undef,"Running TR parser spawns both runs and plans");
  28. $prove = App::Prove->new();
  29. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=bogoRun,version=0.014,testsuite_id=9,sections=fake.test:CARBON LIQUEFACTION",'t/fake.test');
  30. is (exception { capture { $prove->run() } },undef,"Running TR parser can discriminate by sections correctly");
  31. $prove = App::Prove->new();
  32. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=FinalPlan,run=FinalRun,configs=testConfig,version=0.014,autoclose=1",'t/fake.test');
  33. is (exception { capture { $prove->run() } },undef,"Running TR parser with autoclose works correctly");
  34. #Test multi-job upload shizz
  35. #Note that I don't care if it even uploads, just that it *would have* done so correctly.
  36. $prove = App::Prove->new();
  37. $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=FinalPlan,run=FinalRun,configs=testConfig,step_results=step_results", '-j2', 't/fake.test', 't/skipall.test');
  38. is (exception { capture { $prove->run() } },undef,"Running TR parser -j2 works");
  39. my $tres = $prove->state_manager->results->{'tests'};
  40. subtest "Both step_result tracking and raw_output is correct (tests share parser internally)" => sub {
  41. foreach my $test (keys %$tres) {
  42. my $step_results = $tres->{$test}->{'parser'}->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
  43. my $toutput = $tres->{$test}->{'parser'}->{'raw_output'};
  44. note $test;
  45. if ($test eq 't/skipall.test') {
  46. unlike($toutput,qr/STORAGE TANKS SEARED/i,"Test steps in full test output");
  47. isnt(ref $step_results, 'ARRAY', "step_results isnt ARRAY ref");
  48. } else {
  49. like($toutput,qr/STORAGE TANKS SEARED/i,"Test steps in full test output");
  50. unlike($toutput,qr/SKIP/i,"Skip all info in full test output");
  51. if (is(ref $step_results, 'ARRAY', "step_results is ARRAY ref")) {
  52. is(scalar(@$step_results),2,"2 steps to upload for normal test");
  53. }
  54. }
  55. }
  56. };