testrail-tests.t 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. use strict;
  2. use warnings;
  3. use Test::More "tests" => 31;
  4. use Test::Fatal;
  5. use FindBin;
  6. use IO::CaptureOutput qw{capture};
  7. use lib $FindBin::Bin.'/../bin';
  8. require 'testrail-tests';
  9. #check plan mode
  10. my @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{-m t --config testConfig --mock --no-recurse});
  11. my ($out,$code) = TestRail::Bin::Tests::run(@args);
  12. is($code, 0, "Exit code OK running plan mode, no recurse");
  13. chomp $out;
  14. like($out,qr/skipall\.test$/,"Gets test correctly in plan mode, no recurse");
  15. #check no-match
  16. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--no-match t --config testConfig --mock});
  17. ($out,$code) = TestRail::Bin::Tests::run(@args);
  18. is($code, 0, "Exit code OK running plan mode, no match");
  19. chomp $out;
  20. unlike($out,qr/skipall\.test/,"Omits test correctly in plan mode, recurse, no-match");
  21. unlike($out,qr/NOT SO SEARED AFTER ARR/,"Omits non-file test correctly in plan mode, recurse, no-match");
  22. like($out,qr/faker\.test/,"Omits non-file test correctly in plan mode, recurse, no-match");
  23. #check no-match, no recurse
  24. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--no-match t --config testConfig --mock --no-recurse});
  25. ($out,$code) = TestRail::Bin::Tests::run(@args);
  26. is($code, 0, "Exit code OK running plan mode, no match, no recurse");
  27. chomp $out;
  28. unlike($out,qr/skipall\.test/,"Omits test correctly in plan mode, no recurse, no-match");
  29. unlike($out,qr/NOT SO SEARED AFTER ARR/,"Omits non-file test correctly in plan mode, no recurse, no-match");
  30. like($out,qr/faker\.test/,"Omits non-file test correctly in plan mode, no recurse, no-match");
  31. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--config testConfig -m t --mock});
  32. ($out,$code) = TestRail::Bin::Tests::run(@args);
  33. is($code, 0, "Exit code OK running plan mode, recurse");
  34. chomp $out;
  35. like($out,qr/skipall\.test$/,"Gets test correctly in plan mode, recurse");
  36. #check non plan mode
  37. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -r TestingSuite -m t --mock --no-recurse});
  38. ($out,$code) = TestRail::Bin::Tests::run(@args);
  39. is($code, 0, "Exit code OK running no plan mode, no recurse");
  40. chomp $out;
  41. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, no recurse");
  42. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -r TestingSuite -m t --mock});
  43. ($out,$code) = TestRail::Bin::Tests::run(@args);
  44. is($code, 0, "Exit code OK running no plan mode, recurse");
  45. chomp $out;
  46. like($out,qr/skipall\.test$/,"Gets test correctly in no plan mode, recurse");
  47. #Negative case, filtering by config
  48. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{-m t --mock --config testPlatform1});
  49. isnt(exception {TestRail::Bin::Tests::run(@args)}, undef, "Exit code not OK when passing invalid configs for plan");
  50. #check assignedto filters
  51. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--mock --config testConfig --assignedto teodesian});
  52. ($out,$code) = TestRail::Bin::Tests::run(@args);
  53. is($code, 0, "Exit code OK when filtering by assignment");
  54. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by assignment");
  55. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--mock --config testConfig --assignedto billy});
  56. ($out,$code) = TestRail::Bin::Tests::run(@args);
  57. is($code, 255, "Exit code OK when filtering by assignment");
  58. chomp $out;
  59. is($out,"","Gets no tests correctly when filtering by wrong assignment");
  60. #check status filters
  61. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{-m t --mock --config testConfig --status passed});
  62. ($out,$code) = TestRail::Bin::Tests::run(@args);
  63. is($code, 0, "Exit code OK when filtering by status");
  64. like($out,qr/skipall\.test$/,"Gets test correctly when filtering by status");
  65. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -p GosPlan -r}, "Executing the great plan", qw{--mock --config testConfig --status failed});
  66. ($out,$code) = TestRail::Bin::Tests::run(@args);
  67. is($code, 255, "Exit code OK when filtering by status");
  68. chomp $out;
  69. is($out,"","Gets no tests correctly when filtering by wrong status");
  70. #Verify no-match returns non path
  71. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -r TestingSuite --mock});
  72. ($out,$code) = TestRail::Bin::Tests::run(@args);
  73. is($code, 0, "Exit code OK running no plan mode, no-match");
  74. chomp $out;
  75. like($out,qr/\nskipall\.test$/,"Gets test correctly in no plan mode, no-match");
  76. #Verify no-match returns non path
  77. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -r TestingSuite --orphans t --mock});
  78. ($out,$code) = TestRail::Bin::Tests::run(@args);
  79. is($code, 0, "Exit code OK running no plan mode, no recurse");
  80. chomp $out;
  81. like($out,qr/NOT SO SEARED AFTER ARR/,"Gets test correctly in orphan mode");
  82. #Verify no-match returns non path
  83. @args = qw{--help};
  84. $0 = $FindBin::Bin.'/../bin/testrail-tests';
  85. (undef,$code) = capture {TestRail::Bin::Tests::run(@args)} \$out, \$out;
  86. is($code, 0, "Exit code OK asking for help");
  87. like($out,qr/encoding of arguments/i,"Help output OK");