App-Prove-Plugin-Testrail.t 4.3 KB

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