Sfoglia il codice sorgente

Add test for #85, prove I'm not crazy. Also correct parser typo

George S. Baugh 10 anni fa
parent
commit
102ff8a255
2 ha cambiato i file con 28 aggiunte e 1 eliminazioni
  1. 1 1
      lib/Test/Rail/Parser.pm
  2. 27 0
      t/App-Prove-Plugin-Testrail.t

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

@@ -369,7 +369,7 @@ sub testCallback {
 
     #Don't do anything if we don't want to map TR case => ok or use step-by-step results
     if ( !($self->{'tr_opts'}->{'step_results'} || $self->{'tr_opts'}->{'case_per_ok'}) ) {
-        print "# Neither step_results of case_per_ok set.  No action to be taken, except on a whole test basis.\n" if $self->{'tr_opts'}->{'debug'};
+        print "# Neither step_results or case_per_ok set.  No action to be taken, except on a whole test basis.\n" if $self->{'tr_opts'}->{'debug'};
         return 1;
     }
     if ($self->{'tr_opts'}->{'step_results'} && $self->{'tr_opts'}->{'case_per_ok'}) {

+ 27 - 0
t/App-Prove-Plugin-Testrail.t

@@ -47,3 +47,30 @@ $prove = App::Prove->new();
 $prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=FinalPlan,run=FinalRun,configs=testConfig,version=0.014,case_per_ok=1,autoclose=1",'t/fake.test');
 
 is (exception {$prove->run()},undef,"Running TR parser with autoclose works correctly");
+
+#Test multi-job upload shizz
+$prove = App::Prove->new();
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=FinalPlan,run=FinalRun,configs=testConfig,step_results=step_results", '-j2', 't/fake.test', 't/skipall.test');
+
+is (exception {$prove->run()},undef,"Running TR parser -j2 works");
+
+my $tres = $prove->state_manager->results->{'tests'};
+subtest "Both step_result tracking and raw_output is correct (tests share parser internally)" => sub {
+    foreach my $test (keys %$tres) {
+        my $step_results = $tres->{$test}->{'parser'}->{'tr_opts'}->{'result_custom_options'}->{'step_results'};
+        my $toutput = $tres->{$test}->{'parser'}->{'raw_output'};
+        note $test;
+        if ($test eq 'skipall.test') {
+            unlike($toutput,qr/NOT SO SEARED AFTER ALL/i,"Test steps in full test output");
+            if (is(ref $step_results, 'ARRAY', "step_results is ARRAY ref")) {
+                is(scalar(@$step_results),0,"No steps to upload when doing skip_all");
+            }
+        } else {
+            like($toutput,qr/NOT SO SEARED AFTER ALL/i,"Test steps in full test output");
+            unlike($toutput,qr/SKIP/i,"Skip all info in full test output");
+            if (is(ref $step_results, 'ARRAY', "step_results is ARRAY ref")) {
+                is(scalar(@$step_results),2,"No steps to upload when doing skip_all");
+            }
+        }
+    }
+};