diff --git a/t/81-examples.t b/t/81-examples.t new file mode 100644 index 0000000..06fe47c --- /dev/null +++ b/t/81-examples.t @@ -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; + diff --git a/t/examples/bad-test-count-and-exception.pl b/t/examples/bad-test-count-and-exception.pl new file mode 100644 index 0000000..ac77ac7 --- /dev/null +++ b/t/examples/bad-test-count-and-exception.pl @@ -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(); diff --git a/t/examples/good-test-count-and-exception.pl b/t/examples/good-test-count-and-exception.pl new file mode 100644 index 0000000..83db358 --- /dev/null +++ b/t/examples/good-test-count-and-exception.pl @@ -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();