Test-Rail-Parser.t 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use TestRail::API;
  5. use Test::LWP::UserAgent::TestRailMock;
  6. use Test::Rail::Parser;
  7. use Test::More 'tests' => 12;
  8. use Test::Fatal qw{exception};
  9. #Same song and dance as in TestRail-API.t
  10. my $apiurl = $ENV{'TESTRAIL_API_URL'};
  11. my $login = $ENV{'TESTRAIL_USER'};
  12. my $pw = $ENV{'TESTRAIL_PASSWORD'};
  13. my $is_mock = (!$apiurl && !$login && !$pw);
  14. ($apiurl,$login,$pw) = ('http://testrail.local','teodesian@cpan.org','fake') if $is_mock;
  15. my ($debug,$browser);
  16. if ($is_mock) {
  17. $debug = 1;
  18. $browser = $Test::LWP::UserAgent::TestRailMock::mockObject;
  19. }
  20. #test exceptions...
  21. #TODO
  22. #case_per_ok mode
  23. my $fcontents = "
  24. fake.test ..
  25. 1..2
  26. ok 1 - STORAGE TANKS SEARED
  27. #goo
  28. not ok 2 - NOT SO SEARED AFTER ARR
  29. ";
  30. my $tap;
  31. my $res = exception {
  32. $tap = Test::Rail::Parser->new({
  33. 'tap' => $fcontents,
  34. 'apiurl' => $apiurl,
  35. 'user' => $login,
  36. 'pass' => $pw,
  37. 'debug' => $debug,
  38. 'browser' => $browser,
  39. 'run' => 'TestingSuite',
  40. 'project' => 'TestProject',
  41. 'merge' => 1,
  42. 'case_per_ok' => 1
  43. });
  44. };
  45. is($res,undef,"TR Parser doesn't explode on instantiation");
  46. isa_ok($tap,"Test::Rail::Parser");
  47. if (!$res) {
  48. $tap->run();
  49. is($tap->{'errors'},0,"No errors encountered uploading case results");
  50. }
  51. undef $tap;
  52. $res = exception {
  53. $tap = Test::Rail::Parser->new({
  54. 'source' => 'fake.test',
  55. 'apiurl' => $apiurl,
  56. 'user' => $login,
  57. 'pass' => $pw,
  58. 'debug' => $debug,
  59. 'browser' => $browser,
  60. 'run' => 'TestingSuite',
  61. 'project' => 'TestProject',
  62. 'merge' => 1,
  63. 'case_per_ok' => 1
  64. });
  65. };
  66. is($res,undef,"TR Parser doesn't explode on instantiation");
  67. isa_ok($tap,"Test::Rail::Parser");
  68. if (!$res) {
  69. $tap->run();
  70. is($tap->{'errors'},0,"No errors encountered uploading case results");
  71. }
  72. #Time for non case_per_ok mode
  73. undef $tap;
  74. $res = exception {
  75. $tap = Test::Rail::Parser->new({
  76. 'source' => 'faker.test',
  77. 'apiurl' => $apiurl,
  78. 'user' => $login,
  79. 'pass' => $pw,
  80. 'debug' => $debug,
  81. 'browser' => $browser,
  82. 'run' => 'OtherOtherSuite',
  83. 'project' => 'TestProject',
  84. 'merge' => 1,
  85. 'step_results' => 'step_results'
  86. });
  87. };
  88. is($res,undef,"TR Parser doesn't explode on instantiation");
  89. isa_ok($tap,"Test::Rail::Parser");
  90. if (!$res) {
  91. $tap->run();
  92. is($tap->{'errors'},0,"No errors encountered uploading case results");
  93. }
  94. #Default mode
  95. undef $tap;
  96. $res = exception {
  97. $tap = Test::Rail::Parser->new({
  98. 'source' => 'faker.test',
  99. 'apiurl' => $apiurl,
  100. 'user' => $login,
  101. 'pass' => $pw,
  102. 'debug' => $debug,
  103. 'browser' => $browser,
  104. 'run' => 'OtherOtherSuite',
  105. 'project' => 'TestProject',
  106. 'merge' => 1
  107. });
  108. };
  109. is($res,undef,"TR Parser doesn't explode on instantiation");
  110. isa_ok($tap,"Test::Rail::Parser");
  111. if (!$res) {
  112. $tap->run();
  113. is($tap->{'errors'},0,"No errors encountered uploading case results");
  114. }
  115. 0;