Pārlūkot izejas kodu

Fix #35: fix step_results mode

George S. Baugh 10 gadi atpakaļ
vecāks
revīzija
59deca3e85
2 mainītis faili ar 25 papildinājumiem un 2 dzēšanām
  1. 3 1
      lib/Test/Rail/Parser.pm
  2. 22 1
      t/Test-Rail-Parser.t

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

@@ -117,6 +117,8 @@ sub new {
         'result_custom_options' => delete $opts->{'result_custom_options'}
     };
 
+    confess("case_per_ok and step_results options are mutually exclusive") if ($tropts->{'case_per_ok'} && $tropts->{'step_results'});
+
     #Allow natural confessing from constructor
     my $tr = TestRail::API->new($tropts->{'apiurl'},$tropts->{'user'},$tropts->{'pass'},$tropts->{'debug'});
     $tropts->{'testrail'} = $tr;
@@ -405,7 +407,7 @@ sub EOFCallback {
         $self->{'tr_opts'}->{'result_options'}->{'elapsed'} = _compute_elapsed($self->{'starttime'},time());
     }
 
-    if (!(!$self->{'tr_opts'}->{'step_results'} xor $self->{'tr_opts'}->{'case_per_ok'})) {
+    if ($self->{'tr_opts'}->{'case_per_ok'}) {
         print "Nothing left to do.\n";
         undef $self->{'tr_opts'} unless $self->{'tr_opts'}->{'debug'};
         return 1;

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

@@ -7,7 +7,7 @@ use Scalar::Util qw{reftype};
 use TestRail::API;
 use Test::LWP::UserAgent::TestRailMock;
 use Test::Rail::Parser;
-use Test::More 'tests' => 39;
+use Test::More 'tests' => 40;
 use Test::Fatal qw{exception};
 
 #Same song and dance as in TestRail-API.t
@@ -344,4 +344,25 @@ if (!$res) {
     is($tap->{'errors'},0,"No errors encountered uploading case results");
 }
 
+#Verify that case_per_ok and step_results are mutually exclusive, and die.
+undef $tap;
+$res = exception {
+    $tap = Test::Rail::Parser->new({
+        'source'              => 't/skipall.test',
+        'apiurl'              => $apiurl,
+        'user'                => $login,
+        'pass'                => $pw,
+        'debug'               => $debug,
+        'browser'             => $browser,
+        'run'                 => 'BogoRun',
+        'plan'                => 'BogoPlan',
+        'project'             => 'TestProject',
+        'spawn'               => 9,
+        'merge'               => 1,
+        'case_per_ok'         => 1,
+        'step_results'        => 'sr_step_results'
+    });
+};
+isnt($res,undef,"TR Parser explodes on instantiation when mutually exclusive options are passed");
+
 0;