Sfoglia il codice sorgente

Fix #94: Don't truncate step results when not in case_per_ok

George S. Baugh 9 anni fa
parent
commit
43dbe9ed91
3 ha cambiato i file con 41 aggiunte e 3 eliminazioni
  1. 1 0
      Changes
  2. 3 2
      lib/Test/Rail/Parser.pm
  3. 37 1
      t/Test-Rail-Parser.t

+ 1 - 0
Changes

@@ -5,6 +5,7 @@ Revision history for Perl module TestRail::API
     - Fix issue where TODO PASS was reported in tests with TODO FAILs.
     - Fix issue where TODO FAILED steps were reported as TODO PASS.
     - Fix issue where the value of the step_results field was ignored by Test::Rail::Parser
+    - Fix issue where Test::Rail::Parser would truncate results in non case-per-ok mode
 
 0.034 2016-02-18 TEODESIAN
     - Use Capture::Tiny rahter than IO::CaptureOutput in unit tests

+ 3 - 2
lib/Test/Rail/Parser.pm

@@ -404,8 +404,9 @@ sub testCallback {
         $self->{'errors'}++;
         return 0;
     }
-    #Fail on unplanned tests
-    if ($test->is_unplanned()) {
+
+    #Can't upload unplanned tests when it's case_per_ok
+    if ($test->is_unplanned() && $self->{'tr_opts'}->{'case_per_ok'}) {
         cluck("ERROR: Unplanned test detected.  Will not attempt to upload results.");
         $self->{'errors'}++;
         return 0;

+ 37 - 1
t/Test-Rail-Parser.t

@@ -10,7 +10,7 @@ use Scalar::Util qw{reftype};
 use TestRail::API;
 use Test::LWP::UserAgent::TestRailMock;
 use Test::Rail::Parser;
-use Test::More 'tests' => 112;
+use Test::More 'tests' => 119;
 use Test::Fatal qw{exception};
 use Test::Deep qw{cmp_deeply};
 
@@ -407,6 +407,42 @@ if (!$res) {
 }
 undef $opts->{'step_results'};
 
+#Check unplanned tests
+$fcontents = "
+todo_pass.test ..
+1..1
+ok 1 - STORAGE TANKS SEARED
+ok 2 - ZIPPPEEE
+";
+$opts->{'case_per_ok'} = 1;
+$opts->{'tap'} = $fcontents;
+$res = exception { $tap = Test::Rail::Parser->new($opts) };
+is($res,undef,"TR Parser doesn't explode on instantiation");
+isa_ok($tap,"Test::Rail::Parser");
+
+if (!$res) {
+    $tap->run();
+    is($tap->{'errors'},1,"Error encountered uploading case results w/nonexistent case name in case-per-ok");
+}
+undef $opts->{'case_per_ok'};
+
+#Check unplanned tests
+$fcontents = "
+todo_pass.test ..
+1..1
+ok 1 - STORAGE TANKS SEARED
+ok 2 - ZIPPPEEE
+";
+$opts->{'tap'} = $fcontents;
+$res = exception { $tap = Test::Rail::Parser->new($opts) };
+is($res,undef,"TR Parser doesn't explode on instantiation");
+isa_ok($tap,"Test::Rail::Parser");
+
+if (!$res) {
+    $tap->run();
+    is($tap->{'errors'},0,"No errors encountered uploading case results w/ unplanned tests");
+    is($tap->{'global_status'},5, "Test global result is FAIL when unplanned test seen without case-per-ok");
+}
 
 undef $tap;
 #Check bad plan w/ todo pass logic