testrail-tests.t 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. use strict;
  2. use warnings;
  3. use Test::More 'tests' => 18;
  4. #check plan mode
  5. my @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' -m t --config testConfig --mock --no-recurse});
  6. my $out = `@args`;
  7. is($? >> 8, 0, "Exit code OK running plan mode, no recurse");
  8. chomp $out;
  9. like($out,qr/skipall\.test$/,"Gets test correctly in plan mode, no recurse");
  10. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' --config testConfig -m t --mock});
  11. $out = `@args`;
  12. is($? >> 8, 0, "Exit code OK running plan mode, recurse");
  13. chomp $out;
  14. like($out,qr/skipall\.test$/,"Gets test correctly in plan mode, recurse");
  15. #check non plan mode
  16. @args = ($^X,qw{bin/testrail-tests -j TestProject -r 'TestingSuite' -m t --mock --no-recurse});
  17. $out = `@args`;
  18. is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
  19. chomp $out;
  20. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, no recurse");
  21. @args = ($^X,qw{bin/testrail-tests -j TestProject -r 'TestingSuite' -m t --mock});
  22. $out = `@args`;
  23. is($? >> 8, 0, "Exit code OK running no plan mode, recurse");
  24. chomp $out;
  25. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, recurse");
  26. #Negative case, filtering by config
  27. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' -m t --mock --config testPlatform1});
  28. $out = `@args`;
  29. isnt($? >> 8, 0, "Exit code not OK when passing invalid configs for plan");
  30. chomp $out;
  31. like($out,qr/no such run/i,"Gets test correctly in plan mode, recurse");
  32. #check assignedto filters
  33. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' --mock --config 'testConfig' --assignedto teodesian});
  34. $out = `@args`;
  35. is($? >> 8, 0, "Exit code OK when filtering by assignment");
  36. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by assignment");
  37. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' --mock --config 'testConfig' --assignedto billy});
  38. $out = `@args`;
  39. is($? >> 8, 0, "Exit code OK when filtering by assignement");
  40. chomp $out;
  41. is($out,'',"Gets no tests correctly when filtering by wrong assignment");
  42. #check status filters
  43. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' -m t --mock --config 'testConfig' --status 'passed'});
  44. $out = `@args`;
  45. is($? >> 8, 0, "Exit code OK when filtering by status");
  46. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by status");
  47. @args = ($^X,qw{bin/testrail-tests -j TestProject -p 'GosPlan' -r 'Executing the great plan' --mock --config 'testConfig' --status 'failed'});
  48. $out = `@args`;
  49. is($? >> 8, 0, "Exit code OK when filtering by status");
  50. chomp $out;
  51. is($out,'',"Gets no tests correctly when filtering by wrong status");