testrail-tests.t 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. use strict;
  2. use warnings;
  3. use Test::More "tests" => 20;
  4. #check plan mode
  5. my @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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 --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -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");
  52. #Verify no-match returns non path
  53. @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" --mock});
  54. $out = `@args`;
  55. is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
  56. chomp $out;
  57. like($out,qr/\nskipall\.test$/,"Gets test correctly in no plan mode, no recurse");