testrail-cases.t 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. use strict;
  2. use warnings;
  3. use FindBin;
  4. use lib $FindBin::Bin.'/../bin';
  5. require 'testrail-cases';
  6. use lib $FindBin::Bin.'/lib';
  7. use Test::LWP::UserAgent::TestRailMock;
  8. use Test::More "tests" => 6;
  9. use Capture::Tiny qw{capture_merged};
  10. #check plan mode
  11. my @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -t}, 'HAMBURGER-IZE HUMANITY', qw{-d t --test --extension .test});
  12. my ($out,$code) = TestRail::Bin::Cases::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  13. is($code, 0, "Exit code OK running add, update, orphans");
  14. chomp $out;
  15. like($out,qr/fake\.test/,"Shows existing tests by default");
  16. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -t}, 'HAMBURGER-IZE HUMANITY', qw{-d t -o --extension .test});
  17. ($out,$code) = TestRail::Bin::Cases::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  18. chomp $out;
  19. like($out,qr/nothere\.test/,"Shows orphan tests");
  20. @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -t}, 'HAMBURGER-IZE HUMANITY', qw{-d t -m --extension .test});
  21. ($out,$code) = TestRail::Bin::Cases::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args);
  22. chomp $out;
  23. like($out,qr/t\/skipall\.test/,"Shows missing tests");
  24. #Verify no-match returns non path
  25. @args = qw{--help};
  26. $0 = $FindBin::Bin.'/../bin/testrail-cases';
  27. ($out,(undef,$code)) = capture_merged {TestRail::Bin::Cases::run('args' => \@args)};
  28. is($code, 0, "Exit code OK asking for help");
  29. like($out,qr/encoding of arguments/i,"Help output OK");