testrail-tests.t 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. use strict;
  2. use warnings;
  3. use Test::More "tests" => 32;
  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. #check no-match
  11. @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" --no-match t --config testConfig --mock});
  12. $out = `@args`;
  13. is($? >> 8, 0, "Exit code OK running plan mode, no match");
  14. chomp $out;
  15. unlike($out,qr/skipall\.test/,"Omits test correctly in plan mode, recurse, no-match");
  16. unlike($out,qr/NOT SO SEARED AFTER ARR/,"Omits non-file test correctly in plan mode, recurse, no-match");
  17. like($out,qr/faker\.test/,"Omits non-file test correctly in plan mode, recurse, no-match");
  18. #check no-match, no recurse
  19. @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" --no-match t --config testConfig --mock --no-recurse});
  20. $out = `@args`;
  21. is($? >> 8, 0, "Exit code OK running plan mode, no match, no recurse");
  22. chomp $out;
  23. unlike($out,qr/skipall\.test/,"Omits test correctly in plan mode, no recurse, no-match");
  24. unlike($out,qr/NOT SO SEARED AFTER ARR/,"Omits non-file test correctly in plan mode, no recurse, no-match");
  25. like($out,qr/faker\.test/,"Omits non-file test correctly in plan mode, no recurse, no-match");
  26. @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});
  27. $out = `@args`;
  28. is($? >> 8, 0, "Exit code OK running plan mode, recurse");
  29. chomp $out;
  30. like($out,qr/skipall\.test$/,"Gets test correctly in plan mode, recurse");
  31. #check non plan mode
  32. @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});
  33. $out = `@args`;
  34. is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
  35. chomp $out;
  36. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, no recurse");
  37. @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" -m t --mock});
  38. $out = `@args`;
  39. is($? >> 8, 0, "Exit code OK running no plan mode, recurse");
  40. chomp $out;
  41. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, recurse");
  42. #Negative case, filtering by config
  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 testPlatform1});
  44. $out = `@args`;
  45. isnt($? >> 8, 0, "Exit code not OK when passing invalid configs for plan");
  46. #check assignedto filters
  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" --assignedto teodesian});
  48. $out = `@args`;
  49. is($? >> 8, 0, "Exit code OK when filtering by assignment");
  50. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by assignment");
  51. @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});
  52. $out = `@args`;
  53. is($? >> 8, 0, "Exit code OK when filtering by assignment");
  54. chomp $out;
  55. is($out,"","Gets no tests correctly when filtering by wrong assignment");
  56. #check status filters
  57. @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"});
  58. $out = `@args`;
  59. is($? >> 8, 0, "Exit code OK when filtering by status");
  60. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by status");
  61. @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"});
  62. $out = `@args`;
  63. is($? >> 8, 0, "Exit code OK when filtering by status");
  64. chomp $out;
  65. is($out,"","Gets no tests correctly when filtering by wrong status");
  66. #Verify no-match returns non path
  67. @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" --mock});
  68. $out = `@args`;
  69. is($? >> 8, 0, "Exit code OK running no plan mode, no-match");
  70. chomp $out;
  71. like($out,qr/\nskipall\.test$/,"Gets test correctly in no plan mode, no-match");
  72. #Verify no-match returns non path
  73. @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" --orphans t --mock});
  74. $out = `@args`;
  75. is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
  76. chomp $out;
  77. like($out,qr/NOT SO SEARED AFTER ARR/,"Gets test correctly in orphan mode");
  78. #Verify no-match returns non path
  79. @args = ($^X,qw{bin/testrail-tests --help});
  80. $out = `@args`;
  81. is($? >> 8, 0, "Exit code OK asking for help");
  82. like($out,qr/encoding of arguments/i,"Help output OK");
  83. #Verify no-match and match are mutually exclusive
  84. @args = ($^X,qw{bin/testrail-tests --no-match t --match t/qa --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" --mock});
  85. $out = `@args`;
  86. isnt($? >> 8, 0, "Exit code not OK asking for mutually exclusive match options");