testrail-report.t 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. use strict;
  2. use warnings;
  3. use Test::More 'tests' => 16;
  4. my @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "CRUSH ALL HUMANS" --run "SEND T-1000 INFILTRATION UNITS BACK IN TIME" --mock t/test_multiple_files.tap});
  5. my $out = `@args`;
  6. is($? >> 8, 0, "Exit code OK reported with multiple files");
  7. my $matches = () = $out =~ m/Reporting result of case/ig;
  8. is($matches,2,"Attempts to upload multiple times");
  9. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "CRUSH ALL HUMANS" --run "SEND T-1000 INFILTRATION UNITS BACK IN TIME" --case-ok --mock t/test_multiple_files.tap});
  10. $out = `@args`;
  11. is($? >> 8, 0, "Exit code OK reported with multiple files (case-ok mode)");
  12. $matches = () = $out =~ m/Reporting result of case/ig;
  13. is($matches,4,"Attempts to upload multiple times (case-ok mode)");
  14. #Test version, case-ok
  15. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "TestingSuite" --case-ok --version '1.0.14' --mock t/test_subtest.tap});
  16. $out = `@args`;
  17. is($? >> 8, 0, "Exit code OK reported with subtests (case-ok mode)");
  18. $matches = () = $out =~ m/Reporting result of case/ig;
  19. is($matches,2,"Attempts to upload do not do subtests (case-ok mode)");
  20. #Test plans/configs
  21. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "Executing the great plan" --plan "GosPlan" --config "testConfig" --case-ok --mock t/test_subtest.tap});
  22. $out = `@args`;
  23. is($? >> 8, 0, "Exit code OK reported with plans");
  24. $matches = () = $out =~ m/Reporting result of case.*OK/ig;
  25. is($matches,2,"Attempts to to plans work");
  26. #Test that spawn works
  27. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "TestingSuite2" --spawn 9 --case-ok --mock t/test_subtest.tap});
  28. $out = `@args`;
  29. is($? >> 8, 0, "Exit code OK reported with spawn");
  30. $matches = () = $out =~ m/Reporting result of case.*OK/ig;
  31. is($matches,2,"Attempts to spawn work");
  32. #Test that spawn works w/sections
  33. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "TestingSuite2" --spawn 9 --case-ok --section "CARBON LIQUEFACTION" --mock t/test_subtest.tap});
  34. $out = `@args`;
  35. is($? >> 8, 0, "Exit code OK reported with spawn");
  36. $matches = () = $out =~ m/with specified sections/ig;
  37. is($matches,1,"Attempts to spawn work");
  38. #Test that the autoclose option works
  39. @args = ($^X,qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "FinalRun" --plan "FinalPlan" --config "testConfig" --case-ok --autoclose --mock t/fake.tap});
  40. $out = `@args`;
  41. is($? >> 8, 0, "Exit code OK when doing autoclose");
  42. like($out,qr/closing plan/i,"Run closure reported to user");
  43. #Test that help works
  44. @args = ($^X,qw{bin/testrail-report --help});
  45. $out = `@args`;
  46. is($? >> 8, 0, "Exit code OK reported with help");
  47. $matches = () = $out =~ m/usage/ig;
  48. is($matches,1,"Help output OK");