Просмотр исходного кода

Fix #96 : remove case_per_ok feature

George S. Baugh 9 лет назад
Родитель
Сommit
69f1df0ab8

+ 1 - 0
Changes

@@ -6,6 +6,7 @@ Revision history for Perl module TestRail::API
     - 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
+    - Remove case_per_ok feature from Test::Rail::Parser, never really worked it turns out
 
 0.034 2016-02-18 TEODESIAN
     - Use Capture::Tiny rahter than IO::CaptureOutput in unit tests

+ 0 - 2
bin/testrail-lock

@@ -20,8 +20,6 @@ Results, however have a history of results set, so we use that fact to detect if
 
 Will respect test priority when making the choice of what test to lock.
 
-This obviously does not make sense with case_per_ok test upload; support for locking entire sections when in case_per_ok upload mode is not supported at this time.
-
 Can also be used as the modulino TestRail::Bin::Lock.
 Has a single 'run' function which accepts a hash with the 'args' parameter being the array of arguments.
 

+ 0 - 2
bin/testrail-report

@@ -138,7 +138,6 @@ sub run {
         'password=s'     => \$opts{password},
         'user=s'         => \$opts{user},
         'project=s'      => \$opts{project},
-        'case-ok'        => \$opts{case_per_ok},
         'step-results=s' => \$opts{step_results},
         'config=s@'      => \$opts{configs},
         'plan=s'         => \$opts{plan},
@@ -185,7 +184,6 @@ sub run {
             'pass'           => $opts{password},
             'run'            => $opts{run},
             'project'        => $opts{project},
-            'case_per_ok'    => $opts{case_per_ok},
             'step_results'   => $opts{step_results},
             'debug'          => $opts{debug},
             'browser'        => $opts{browser},

+ 0 - 2
lib/App/Prove/Plugin/TestRail.pm

@@ -33,7 +33,6 @@ If \$HOME/.testrailrc exists, it will be parsed for any of these values in a new
     plan=GosPlan
     configs=config1:config2:config3: ... :configN
     version=xx.xx.xx.xx
-    case_per_ok=0
     step_results=sr_sys_name
     lockname=internal_lock_name
     testsuite_id=123
@@ -99,7 +98,6 @@ sub load {
     $ENV{'TESTRAIL_PLAN'}      = $params->{plan};
     $ENV{'TESTRAIL_CONFIGS'}   = $params->{configs};
     $ENV{'TESTRAIL_VERSION'}   = $params->{version};
-    $ENV{'TESTRAIL_CASEOK'}    = $params->{case_per_ok};
     $ENV{'TESTRAIL_STEPS'}     = $params->{step_results};
     $ENV{'TESTRAIL_SPAWN'}     = $params->{testsuite_id};
     $ENV{'TESTRAIL_TESTSUITE'} = $params->{testsuite};

+ 0 - 1
lib/Test/Rail/Harness.pm

@@ -53,7 +53,6 @@ sub make_parser {
     @configs = split(/:/,$ENV{'TESTRAIL_CONFIGS'}) if $ENV{'TESTRAIL_CONFIGS'};
     $args->{'configs'}        = \@configs if scalar(@configs);
     $args->{'result_options'} = {'version' => $ENV{'TESTRAIL_VERSION'}} if $ENV{'TESTRAIL_VERSION'};
-    $args->{'case_per_ok'}    = $ENV{'TESTRAIL_CASEOK'};
     $args->{'step_results'}   = $ENV{'TESTRAIL_STEPS'};
     $args->{'testsuite_id'}   = $ENV{'TESTRAIL_SPAWN'};
     $args->{'testsuite'}      = $ENV{'TESTRAIL_TESTSUITE'};

+ 20 - 68
lib/Test/Rail/Parser.pm

@@ -62,9 +62,7 @@ Get the TAP Parser ready to talk to TestRail, and register a bunch of callbacks
 
 =item B<project_id> - INTEGER (optional): ID of project containing your desired run.  Required if project not passed.
 
-=item B<step_results> - STRING (optional): 'internal name' of the 'step_results' type field available for your project.  Mutually exclusive with case_per_ok
-
-=item B<case_per_ok> - BOOLEAN (optional): Consider test files to correspond to section names, and test steps (OKs) to correspond to tests in TestRail.  Mutually exclusive with step_results.
+=item B<step_results> - STRING (optional): 'internal name' of the 'step_results' type field available for your project.
 
 =item B<result_options> - HASHREF (optional): Extra options to set with your result.  See L<TestRail::API>'s createTestResults function for more information.
 
@@ -84,14 +82,13 @@ Get the TAP Parser ready to talk to TestRail, and register a bunch of callbacks
 
 =back
 
-It is worth noting that if neither step_results or case_per_ok is passed, that the test will be passed if it has no problems of any sort, failed otherwise.
 In both this mode and step_results, the file name of the test is expected to correspond to the test name in TestRail.
 
 This module also attempts to calculate the elapsed time to run each test if it is run by a prove plugin rather than on raw TAP.
 
 The constructor will terminate if the statuses 'pass', 'fail', 'retest', 'skip', 'todo_pass', and 'todo_fail' are not registered as result internal names in your TestRail install.
 
-If you are not in case_per_ok mode, the global status of the case will be set according to the following rules:
+The global status of the case will be set according to the following rules:
 
     1. If there are no issues whatsoever besides TODO failing tests & skips, mark as PASS
     2. If there are any non-skipped or TODOed fails OR a bad plan (extra/missing tests), mark as FAIL
@@ -146,7 +143,6 @@ sub new {
         'project'      => delete $opts->{'project'},
         'project_id'   => delete $opts->{'project_id'},
         'step_results' => delete $opts->{'step_results'},
-        'case_per_ok'  => delete $opts->{'case_per_ok'},
         'plan'         => delete $opts->{'plan'},
         'configs'      => delete $opts->{'configs'} // [],
         'testsuite_id' => delete $opts->{'testsuite_id'},
@@ -160,7 +156,6 @@ sub new {
     };
 
     confess("plan passed, but no run passed!") if !$tropts->{'run'} && $tropts->{'plan'};
-    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->{'encoding'},$tropts->{'debug'});
@@ -342,6 +337,7 @@ sub unknownCallback {
     #try to pick out the filename if we are running this on TAP in files, where App::Prove is uninvolved
     my $file = TestRail::Utils::getFilenameFromTapLine($line);
     $self->{'file'} = $file if $file;
+    return;
 }
 
 =head2 commentCallback
@@ -361,17 +357,13 @@ sub commentCallback {
     if ($line =~ m/^#TESTDESC:\s*/) {
         $self->{'tr_opts'}->{'test_desc'} = $line;
         $self->{'tr_opts'}->{'test_desc'} =~ s/^#TESTDESC:\s*//g;
-        return;
     }
-
-    #keep all comments before a test that aren't these special directives to save in NOTES field of reportTCResult
-    $self->{'tr_opts'}->{'test_notes'} .= "$line\n";
+    return;
 }
 
 =head2 testCallback
 
 If we are using step_results, append it to the step results array for use at EOF.
-If we are using case_per_ok, update TestRail per case.
 Otherwise, do nothing.
 
 =cut
@@ -388,33 +380,19 @@ sub testCallback {
         $self->{'lasttime'} = $tm;
     }
 
-    #Default assumption is that case name is step text (case_per_ok), unless...
     my $line = $test->as_string;
     my $tline = $line;
     $tline = "[".strftime("%H:%M:%S %b %e %Y",localtime($self->{'lasttime'}))." ($self->{elapse_display})] $line" if $self->{'track_time'};
     $self->{'raw_output'} .= "$tline\n";
 
     #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 or case_per_ok set.  No action to be taken, except on a whole test basis.\n" if $self->{'tr_opts'}->{'debug'};
+    if ( !$self->{'tr_opts'}->{'step_results'} ) {
+        print "# step_results not 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'}) {
-        cluck("ERROR: step_options and case_per_ok options are mutually exclusive!");
-        $self->{'errors'}++;
-        return 0;
-    }
-
-    #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;
-    }
 
     $line =~ s/^(ok|not ok)\s[0-9]*\s-\s//g;
     my $test_name  = $line;
-    my $run_id     = $self->{'tr_opts'}->{'run_id'};
 
     print "# Assuming test name is '$test_name'...\n" if $self->{'tr_opts'}->{'debug'} && !$self->{'tr_opts'}->{'step_results'};
 
@@ -456,36 +434,19 @@ sub testCallback {
     #If this is a TODO, set the reason in the notes
     $self->{'tr_opts'}->{'test_notes'} .= "\nTODO reason: $todo_reason\n" if $todo_reason;
 
-    #Setup step options and exit if that's the mode we be rollin'
-    if ($self->{'tr_opts'}->{'step_results'}) {
-        my $sr_sys_name = $self->{'tr_opts'}->{'step_results'}->{'name'};
-        $self->{'tr_opts'}->{'result_custom_options'} = {} if !defined $self->{'tr_opts'}->{'result_custom_options'};
-        $self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name} = [] if !defined $self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name};
-        #TimeStamp every particular step
-
-        $line = "[".strftime("%H:%M:%S %b %e %Y",localtime($self->{'lasttime'}))." ($self->{elapse_display})] $line" if $self->{'track_time'};
-        #XXX Obviously getting the 'expected' and 'actual' from the tap DIAGs would be ideal
-        push(
-            @{$self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name}},
-            TestRail::API::buildStepResults($line,"OK",$status_name,$status)
-        );
-        print "# Appended step results.\n" if $self->{'tr_opts'}->{'debug'};
-        return 1;
-    }
-
-    #Optional args
-    my $notes          = $self->{'tr_opts'}->{'test_notes'};
-    my $options        = $self->{'tr_opts'}->{'result_options'};
-    my $custom_options = $self->{'tr_opts'}->{'result_custom_options'};
-
-    $self->_set_result($run_id,$test_name,$status,$notes,$options,$custom_options);
-    #Re-start the shot clock
-    $self->{'starttime'} = time();
-
-    #Blank out test description in anticipation of next test
-    # also blank out notes
-    $self->{'tr_opts'}->{'test_notes'} = undef;
-    $self->{'tr_opts'}->{'test_desc'} = undef;
+    my $sr_sys_name = $self->{'tr_opts'}->{'step_results'}->{'name'};
+    $self->{'tr_opts'}->{'result_custom_options'} = {} if !defined $self->{'tr_opts'}->{'result_custom_options'};
+    $self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name} = [] if !defined $self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name};
+    #TimeStamp every particular step
+
+    $line = "[".strftime("%H:%M:%S %b %e %Y",localtime($self->{'lasttime'}))." ($self->{elapse_display})] $line" if $self->{'track_time'};
+    #XXX Obviously getting the 'expected' and 'actual' from the tap DIAGs would be ideal
+    push(
+        @{$self->{'tr_opts'}->{'result_custom_options'}->{$sr_sys_name}},
+        TestRail::API::buildStepResults($line,"OK",$status_name,$status)
+    );
+    print "# Appended step results.\n" if $self->{'tr_opts'}->{'debug'};
+    return 1;
 }
 
 =head2 bailoutCallback
@@ -516,7 +477,6 @@ sub bailoutCallback {
 =head2 EOFCallback
 
 If we are running in step_results mode, send over all the step results to TestRail.
-If we are running in case_per_ok mode, do nothing.
 Otherwise, upload the overall results of the test to TestRail.
 
 =cut
@@ -529,13 +489,6 @@ sub EOFCallback {
         $self->{'tr_opts'}->{'result_options'}->{'elapsed'} = _compute_elapsed($self->{'starttime'},time());
     }
 
-    if ($self->{'tr_opts'}->{'case_per_ok'}) {
-        print "# Nothing left to do.\n";
-        $self->_test_closure();
-        undef $self->{'tr_opts'} unless $self->{'tr_opts'}->{'debug'};
-        return 1;
-    }
-
     #Fail if the file is not set
     if (!defined($self->{'file'})) {
         cluck("ERROR: Cannot detect filename, will not be able to find a Test Case with that name");
@@ -572,8 +525,7 @@ sub EOFCallback {
     }
 
     #Optional args
-    my $notes          = $self->{'tr_opts'}->{'test_notes'};
-    $notes = $self->{'raw_output'};
+    my $notes          = $self->{'raw_output'};
     my $options        = $self->{'tr_opts'}->{'result_options'};
     my $custom_options = $self->{'tr_opts'}->{'result_custom_options'};
 

+ 0 - 1
lib/TestRail/Utils/Find.pm

@@ -144,7 +144,6 @@ sub getTests {
 
     my (undef,undef,$run) = TestRail::Utils::getRunInformation($tr,$opts);
     my ($status_ids,$user_ids);
-
     #Process statuses
     @$status_ids = $tr->statusNamesToIds(@{$opts->{'statuses'}}) if $opts->{'statuses'};
 

+ 14 - 13
t/App-Prove-Plugin-Testrail.t

@@ -8,6 +8,7 @@ use lib "$FindBin::Bin/lib";
 
 use Test::More 'tests' => 8;
 use Test::Fatal;
+use Capture::Tiny qw{capture};
 use App::Prove;
 use App::Prove::Plugin::TestRail;
 
@@ -16,44 +17,44 @@ $ENV{'TESTRAIL_MOCKED'} = 1;
 
 #Test the same sort of data as would come from the Test::Rail::Parser case
 my $prove = App::Prove->new();
-$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite,version=0.014,case_per_ok=1",'t/fake.test');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite,version=0.014",'t/fake.test');
 
-is (exception {$prove->run()},undef,"Running TR parser case via plugin functions");
+is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions");
 
 #Check that plan, configs and version also make it through
 $prove = App::Prove->new();
-$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=Executing the great plan,version=0.014,case_per_ok=1,plan=GosPlan,configs=testConfig",'t/fake.test');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=Executing the great plan,version=0.014,plan=GosPlan,configs=testConfig",'t/fake.test');
 
-is (exception {$prove->run()},undef,"Running TR parser case via plugin functions works with configs/plans");
+is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions works with configs/plans");
 
 #Check that spawn options make it through
 
 $prove = App::Prove->new();
-$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite2,version=0.014,case_per_ok=1,testsuite_id=9",'t/skipall.test');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=TestingSuite2,version=0.014,testsuite_id=9",'t/skipall.test');
 
-is (exception {$prove->run()},undef,"Running TR parser case via plugin functions works with configs/plans");
+is (exception { capture { $prove->run() } },undef,"Running TR parser case via plugin functions works with configs/plans");
 
 $prove = App::Prove->new();
-$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=bogoPlan,run=bogoRun,version=0.014,case_per_ok=1,testsuite=HAMBURGER-IZE HUMANITY",'t/skipall.test');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=bogoPlan,run=bogoRun,version=0.014,testsuite=HAMBURGER-IZE HUMANITY",'t/skipall.test');
 
-is (exception {$prove->run()},undef,"Running TR parser spawns both runs and plans");
+is (exception { capture { $prove->run() } },undef,"Running TR parser spawns both runs and plans");
 
 $prove = App::Prove->new();
-$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=bogoRun,version=0.014,case_per_ok=1,testsuite_id=9,sections=fake.test:CARBON LIQUEFACTION",'t/fake.test');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,run=bogoRun,version=0.014,testsuite_id=9,sections=fake.test:CARBON LIQUEFACTION",'t/fake.test');
 
-is (exception {$prove->run()},undef,"Running TR parser can discriminate by sections correctly");
+is (exception { capture { $prove->run() } },undef,"Running TR parser can discriminate by sections correctly");
 
 $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');
+$prove->process_args("-PTestRail=apiurl=http://some.testlink.install/,user=someUser,password=somePassword,project=TestProject,plan=FinalPlan,run=FinalRun,configs=testConfig,version=0.014,autoclose=1",'t/fake.test');
 
-is (exception {$prove->run()},undef,"Running TR parser with autoclose works correctly");
+is (exception { capture { $prove->run() } },undef,"Running TR parser with autoclose works correctly");
 
 #Test multi-job upload shizz
 #Note that I don't care if it even uploads, just that it *would have* done so correctly.
 $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");
+is (exception { capture { $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 {

+ 4 - 40
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' => 119;
+use Test::More 'tests' => 115;
 use Test::Fatal qw{exception};
 use Test::Deep qw{cmp_deeply};
 
@@ -31,7 +31,6 @@ if ($is_mock) {
 #test exceptions...
 #TODO
 
-#case_per_ok mode
 my $fcontents = "
 fake.test ..
 1..2
@@ -51,7 +50,6 @@ my $opts = {
     'run'                 => 'TestingSuite',
     'project'             => 'TestProject',
     'merge'               => 1,
-    'case_per_ok'         => 1
 };
 
 my $res = exception { $tap = Test::Rail::Parser->new($opts) };
@@ -75,7 +73,8 @@ if (!$res) {
     is($tap->{'errors'},0,"No errors encountered uploading case results");
 }
 
-$fcontents = "ok 1 - STORAGE TANKS SEARED
+$fcontents = "fake.test...
+ok 1 - STORAGE TANKS SEARED
 # whee
 not ok 2 - NOT SO SEARED AFTER ARR
 
@@ -99,11 +98,9 @@ is(Test::Rail::Parser::_compute_elapsed(0,61),'1m 1s',"Elapsed computation corre
 is(Test::Rail::Parser::_compute_elapsed(0,3661),'1h 1m 1s',"Elapsed computation correct at hour boundary");
 is(Test::Rail::Parser::_compute_elapsed(0,86461),'24h 1m 1s',"Elapsed computation correct at day boundary");
 
-#Time for non case_per_ok mode
 undef $tap;
 $opts->{'source'} = 't/faker.test';
 $opts->{'run'} = 'OtherOtherSuite';
-delete $opts->{'case_per_ok'};
 $opts->{'step_results'} = 'step_results';
 
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
@@ -115,7 +112,6 @@ if (!$res) {
     is($tap->{'errors'},0,"No errors encountered uploading case results");
     is($tap->{'global_status'},5, "Test global result is FAIL when one subtest fails even if there are TODO passes");
     subtest 'Timestamp/elapsed printed in step results' => sub {
-        diag explain $tap->{'tr_opts'}->{'result_custom_options'};
         foreach my $result (@{$tap->{'tr_opts'}->{'result_custom_options'}->{'step_results'}}) {
             like($result->{'content'}, qr/^\[.*\(.*\)\]/i, "Timestamp printed in step results");
         }
@@ -152,7 +148,6 @@ $opts->{'tap'} = $fcontents;
 delete $opts->{'source'};
 delete $opts->{'step_results'};
 $opts->{'run'} = 'TestingSuite';
-$opts->{'case_per_ok'} = 1;
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
 is($res,undef,"TR Parser doesn't explode on instantiation");
 isa_ok($tap,"Test::Rail::Parser");
@@ -162,7 +157,6 @@ if (!$res) {
     is($tap->{'errors'},0,"No errors encountered uploading case results");
 }
 
-#skip/todo in case_per_ok
 undef $tap;
 delete $opts->{'tap'};
 $opts->{'source'} = 't/skip.test';
@@ -178,7 +172,6 @@ if (!$res) {
 #Default mode skip (skip_all)
 undef $tap;
 $opts->{'source'} = 't/skipall.test';
-delete $opts->{'case_per_ok'};
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
 is($res,undef,"TR Parser doesn't explode on instantiation");
 isa_ok($tap,"Test::Rail::Parser");
@@ -254,13 +247,6 @@ 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;
-$opts->{'case_per_ok'} = 1;
-$opts->{'step_results'} = 'step_results';
-$res = exception { $tap = Test::Rail::Parser->new($opts) };
-isnt($res,undef,"TR Parser explodes on instantiation when mutually exclusive options are passed");
-
 #Check that per-section spawn works
 undef $tap;
 $opts->{'source'} = 't/fake.test';
@@ -297,7 +283,6 @@ isnt($res,undef,"TR Parser explodes on instantiation with invalid section");
 undef $tap;
 $opts->{'source'} = 't/notests.test';
 delete $opts->{'sections'};
-delete $opts->{'case_per_ok'};
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
 is($res,undef,"TR Parser doesn't explode on instantiation");
 isa_ok($tap,"Test::Rail::Parser");
@@ -407,25 +392,6 @@ 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 ..
@@ -495,13 +461,12 @@ if (!$res) {
     is($tap->{'run_closed'},undef, "Run not closed by parser when results are outstanding");
 }
 
-#Check that autoclose works against plan wiht all tests in run status
+#Check that autoclose works against plan with all tests in run status
 undef $tap;
 $opts->{'source'} = 't/fake.test';
 $opts->{'run'} = 'FinalRun';
 $opts->{'plan'} = 'FinalPlan';
 $opts->{'configs'} = ['testConfig'];
-$opts->{'case_per_ok'} = 1;
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
 is($res,undef,"TR Parser doesn't explode on instantiation");
 isa_ok($tap,"Test::Rail::Parser");
@@ -570,7 +535,6 @@ Bail out!  #YOLO
 undef $opts->{'source'};
 $opts->{'tap'} = $fcontents;
 $opts->{'step_results'} = 'step_results';
-undef $opts->{'case_per_ok'};
 $res = exception { $tap = Test::Rail::Parser->new($opts) };
 is($res,undef,"TR Parser runs all the way through on bailout");
 

+ 5 - 5
t/TestRail-Utils-Find.t

@@ -88,7 +88,7 @@ $opts = {
 
 my ($cases) = TestRail::Utils::Find::getTests($opts,$tr);
 my @tests = TestRail::Utils::Find::findTests($opts,@$cases);
-@expected = ("$FindBin::Bin/skipall.test");
+@expected = ("$FindBin::Bin/fake.test","$FindBin::Bin/skip.test","$FindBin::Bin/skipall.test");
 cmp_deeply(\@tests,\@expected,"findTests: match, no-recurse, plan mode, names-only");
 
 delete $opts->{'names-only'};
@@ -105,7 +105,7 @@ $opts->{'extension'} = '.test';
 is(scalar(grep {$_ eq 'skipall.test'} @tests),0,"Tests in tree are not returned in no-match mode");
 is(scalar(grep {$_ eq 'NOT SO SEARED AFTER ALL'} @tests),0,"Tests not in tree that do exist are not returned in no-match mode");
 is(scalar(grep {$_ eq $FindBin::Bin.'/faker.test'} @tests),1,"Orphan Tests in tree ARE returned in no-match mode");
-is(scalar(@tests),7,"Correct number of non-existant cases shown (no-match, names-only)");
+is(scalar(@tests),5,"Correct number of non-existant cases shown (no-match, names-only)");
 
 $opts->{'configs'} = ['testPlatform1'];
 isnt(exception { TestRail::Utils::Find::getTests($opts,$tr) } , undef,"Correct number of non-existant cases shown (no-match, names-only)");
@@ -115,13 +115,13 @@ delete $opts->{'names-only'};
 @tests = TestRail::Utils::Find::findTests($opts,@$cases);
 my @filtered_tests = grep {defined $_} map {$_->{'full_title'}} @tests;
 is(scalar(@filtered_tests),0,"Full titles not returned in no-match mode");
-is(scalar(@tests),7,"Correct number of nonexistant cases shown in no-match mode");
+is(scalar(@tests),5,"Correct number of nonexistant cases shown in no-match mode");
 
 delete $opts->{'no-recurse'};
 $opts->{'names-only'} = 1;
 ($cases) = TestRail::Utils::Find::getTests($opts,$tr);
 @tests = TestRail::Utils::Find::findTests($opts,@$cases);
-is(scalar(@tests),11,"Correct number of non-existant cases shown (no-match, names-only, recurse)");
+is(scalar(@tests),9,"Correct number of non-existant cases shown (no-match, names-only, recurse)");
 
 #mutual excl
 $opts->{'match'} = $FindBin::Bin;
@@ -145,7 +145,7 @@ delete $opts->{'plan'};
 $opts->{'run'} = 'TestingSuite';
 ($cases) = TestRail::Utils::Find::getTests($opts,$tr);
 @tests = TestRail::Utils::Find::findTests($opts,@$cases);
-is(scalar(@tests),1,"Correct number of non-existant cases shown (match, plain run)");
+is(scalar(@tests),3,"Correct number of non-existant cases shown (match, plain run)");
 is(scalar(grep {$_ eq "$FindBin::Bin/skipall.test"} @tests),1,"Tests in tree are returned in match, plain run mode");
 
 #Now that we've made sure configs are ignored...

+ 3 - 3
t/lib/Test/LWP/UserAgent/TestRailMock.pm

@@ -1294,7 +1294,7 @@ $VAR4 = bless( {
                  'content-type' => 'application/json; charset=utf-8',
                  'server' => 'Apache/2.4.7 (Ubuntu)'
                }, 'HTTP::Headers' );
-$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"STORAGE TANKS SEARED","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"NOT SO SEARED AFTER ARR"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":1,"run_id":22,"title":"skipall.test"} ]';
+$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"fake.test","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"skip.test"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":1,"run_id":22,"title":"NOT SO SEARED AFTER ARR"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":1,"run_id":22,"title":"skipall.test"}]';
 $mockObject->map_response(qr/\Q$VAR1\E$/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
 
 }
@@ -1349,7 +1349,7 @@ $VAR4 = bless( {
                  'content-type' => 'application/json; charset=utf-8',
                  'server' => 'Apache/2.4.7 (Ubuntu)'
                }, 'HTTP::Headers' );
-$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"STORAGE TANKS SEARED","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"NOT SO SEARED AFTER ARR"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":1,"run_id":22,"title":"skipall.test"} ]';
+$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"fake.test","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"skip.test"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":1,"run_id":22,"title":"skipall.test"} ]';
 $mockObject->map_response(qr/\Q$VAR1\E$/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
 
 }
@@ -1377,7 +1377,7 @@ $VAR4 = bless( {
                  'content-type' => 'application/json; charset=utf-8',
                  'server' => 'Apache/2.4.7 (Ubuntu)'
                }, 'HTTP::Headers' );
-$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"STORAGE TANKS SEARED","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"NOT SO SEARED AFTER ARR"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"skipall.test"},{"id":16,"case_id":9,"status_id":3,"assignedto_id":null,"run_id":22,"title":"notests.test"},{"id":17,"case_id":10,"status_id":1,"assignedto_id":null,"run_id":22,"title":"pass.test"},{"id":18,"case_id":10,"status_id":1,"assignedto_id":null,"run_id":22,"title":"todo_pass.test"}]';
+$VAR5 = '[{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"fake.test","type_id":6,"priority_id":4,"estimate":null,"estimate_forecast":null,"refs":null,"milestone_id":null,"custom_preconds":null,"custom_steps":null,"custom_expected":null},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"skip.test"},{"id":15,"case_id":8,"status_id":3,"assignedto_id":null,"run_id":22,"title":"skipall.test"},{"id":16,"case_id":9,"status_id":3,"assignedto_id":null,"run_id":22,"title":"notests.test"},{"id":17,"case_id":10,"status_id":1,"assignedto_id":null,"run_id":22,"title":"pass.test"},{"id":18,"case_id":10,"status_id":1,"assignedto_id":null,"run_id":22,"title":"todo_pass.test"}]';
 $mockObject->map_response(qr/\Q$VAR1\E$/,HTTP::Response->new($VAR2, $VAR3, $VAR4, $VAR5));
 
 }

+ 9 - 15
t/testrail-report.t

@@ -5,7 +5,7 @@ use FindBin;
 use lib $FindBin::Bin.'/../bin';
 require 'testrail-report';
 
-use Test::More 'tests' => 17;
+use Test::More 'tests' => 15;
 use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/lib';
@@ -17,42 +17,36 @@ is($code, 0, "Exit code OK reported with multiple files");
 my $matches = () = $out =~ m/Reporting result of case/ig;
 is($matches,2,"Attempts to upload multiple times");
 
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project}, "CRUSH ALL HUMANS", '--run', "SEND T-1000 INFILTRATION UNITS BACK IN TIME", qw{--case-ok  t/test_multiple_files.tap});
-($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
-is($code, 0, "Exit code OK reported with multiple files (case-ok mode)");
-$matches = () = $out =~ m/Reporting result of case/ig;
-is($matches,4,"Attempts to upload multiple times (case-ok mode)");
-
 #Test version, case-ok
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite --case-ok --version 1.0.14  t/test_subtest.tap});
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite --version 1.0.14  t/test_subtest.tap});
 ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with subtests (case-ok mode)");
 $matches = () = $out =~ m/Reporting result of case/ig;
-is($matches,2,"Attempts to upload do not do subtests (case-ok mode)");
+is($matches,1,"version can be uploaded");
 
 #Test plans/configs
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run}, "Executing the great plan", qw{--plan GosPlan --config testConfig --case-ok  t/test_subtest.tap});
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run}, "Executing the great plan", qw{--plan GosPlan --config testConfig  t/test_subtest.tap});
 ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with plans");
 $matches = () = $out =~ m/Reporting result of case.*OK/ig;
-is($matches,2,"Attempts to to plans work");
+is($matches,1,"Attempts to to plans work");
 
 #Test that spawn works
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite_id 9 --case-ok  t/test_subtest.tap});
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite_id 9  t/test_subtest.tap});
 ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with spawn");
 $matches = () = $out =~ m/Reporting result of case.*OK/ig;
-is($matches,2,"Attempts to spawn work: testsuite_id");
+is($matches,1,"Attempts to spawn work: testsuite_id");
 
 #Test that spawn works w/sections
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite}, "HAMBURGER-IZE HUMANITY", qw{--case-ok --section}, "CARBON LIQUEFACTION", qw{ t/test_subtest.tap});
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite}, "HAMBURGER-IZE HUMANITY", qw{ --section}, "CARBON LIQUEFACTION", qw{ t/test_subtest.tap});
 ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with spawn");
 $matches = () = $out =~ m/with specified sections/ig;
 is($matches,1,"Attempts to spawn work: testsuite name");
 
 #Test that the autoclose option works
-@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run FinalRun --plan FinalPlan --config testConfig --case-ok --autoclose  t/fake.tap});
+@args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run FinalRun --plan FinalPlan --config testConfig --autoclose  t/fake.tap});
 ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK when doing autoclose");
 like($out,qr/closing plan/i,"Run closure reported to user");