Skip to content

Commit

Permalink
add test cases for - Exceptions are swallowed when tests exceed count -
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Feb 23, 2021
1 parent 91475d3 commit 23652f0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
26 changes: 26 additions & 0 deletions t/81-examples.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use strict;
use warnings;

use Test::More;
use Capture::Tiny qw(capture);

subtest good_test_count_and_exception => sub {
my ($out, $err, $exit) = capture { system "$^X t/examples/good-test-count-and-exception.pl" };
is $exit, 256;
cmp_ok index($out, 'not ok 3 - mytest died'), '>', 0;
cmp_ok index($out, '123123'), '>', 0;
cmp_ok index($err, 'mytest died'), '>', 0;
};

subtest bad_test_count_and_exception => sub {
my ($out, $err, $exit) = capture { system "$^X t/examples/bad-test-count-and-exception.pl" };
#is $exit, 256;
#cmp_ok index($out, 'not ok 3 - mytest died'), '>', 0;
#cmp_ok index($out, '123123'), '>', 0;
#cmp_ok index($err, 'mytest died'), '>', 0;
pass;
};


done_testing;

15 changes: 15 additions & 0 deletions t/examples/bad-test-count-and-exception.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Test;

use Test::More;
plan tests => 1;

use parent qw( Test::Class );

sub mytest : Tests(1) {
ok 1;
ok 1;

die 123123;
}

__PACKAGE__->new()->runtests();
15 changes: 15 additions & 0 deletions t/examples/good-test-count-and-exception.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Test;

use Test::More;
plan tests => 1;

use parent qw( Test::Class );

sub mytest : Tests(2) {
ok 1;
ok 1;

die 123123;
}

__PACKAGE__->new()->runtests();

0 comments on commit 23652f0

Please sign in to comment.