testrail-cases.t 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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" => 7;
  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");
  30. #Make sure that the binary itself processes args correctly
  31. $out = `$^X $0 --help`;
  32. like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");