testrail-tests.t 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. chomp $out;
  47. like($out,qr/no such run/i,"Gets test correctly in plan mode, recurse");
  48. #check assignedto filters
  49. @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});
  50. $out = `@args`;
  51. is($? >> 8, 0, "Exit code OK when filtering by assignment");
  52. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by assignment");
  53. @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});
  54. $out = `@args`;
  55. is($? >> 8, 0, "Exit code OK when filtering by assignment");
  56. chomp $out;
  57. is($out,"","Gets no tests correctly when filtering by wrong assignment");
  58. #check status filters
  59. @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"});
  60. $out = `@args`;
  61. is($? >> 8, 0, "Exit code OK when filtering by status");
  62. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by status");
  63. @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"});
  64. $out = `@args`;
  65. is($? >> 8, 0, "Exit code OK when filtering by status");
  66. chomp $out;
  67. is($out,"","Gets no tests correctly when filtering by wrong status");
  68. #Verify no-match returns non path
  69. @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -r "TestingSuite" --mock});
  70. $out = `@args`;
  71. is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
  72. chomp $out;
  73. like($out,qr/\nskipall\.test$/,"Gets test correctly in no plan mode, no recurse");
  74. #Verify no-match returns non path
  75. @args = ($^X,qw{bin/testrail-tests --help});
  76. $out = `@args`;
  77. is($? >> 8, 0, "Exit code OK asking for help");
  78. like($out,qr/encoding of arguments/i,"Help output OK");
  79. #Verify no-match and match are mutually exclusive
  80. @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});
  81. $out = `@args`;
  82. isnt($? >> 8, 0, "Exit code not OK asking for mutually exclusive match options");
  83. like($out,qr/mutually exclusive/i,"Death message OK");