| 1 | use v5.12.0; | ||
| 2 | package Test::Routine::Runner::NoSubtest 0.032; | ||
| 3 | # ABSTRACT: tools for running Test::Routine tests (without using a subtest) | ||
| 4 | |||
| 5 | use Moose; | ||
| 6 | extends 'Test::Routine::Runner'; | ||
| 7 | |||
| 8 | #pod =head1 OVERVIEW | ||
| 9 | #pod | ||
| 10 | #pod This is just a L<Test::Routine::Runner>, but when you call C<run>, it won't | ||
| 11 | #pod wrap the whole thing in a subtest. If you use multiple instances of a | ||
| 12 | #pod Test::Routine object in testing -- constructing it with different parameters | ||
| 13 | #pod for several runs, for example -- this will lead to heartache. If your test is | ||
| 14 | #pod just a single run, though, getting rid of that top-level subtest can simplify | ||
| 15 | #pod your life. | ||
| 16 | #pod | ||
| 17 | #pod Also: if no tests will be run, generally because the C<TEST_METHOD> environment | ||
| 18 | #pod variable didn't select them, then a "skip all" will be issued. | ||
| 19 | #pod | ||
| 20 | #pod =cut | ||
| 21 | |||
| 22 | use Test2::API 1.302045 (); | ||
| 23 | |||
| 24 | sub run { | ||
| 25 | my ($self) = @_; | ||
| 26 | |||
| 27 | my $test_instance = $self->build_test_instance; | ||
| 28 | |||
| 29 | my $ordered_tests = $self->_get_tests($test_instance); | ||
| 30 | |||
| 31 | if (@$ordered_tests == 0) { | ||
| 32 | my $ctx = Test2::API::context; | ||
| 33 | $ctx->plan(0, 'SKIP', "no tests to run"); | ||
| 34 | $ctx->release; | ||
| 35 | |||
| 36 | return; | ||
| 37 | } | ||
| 38 | |||
| 39 | $self->_run_tests($test_instance, $ordered_tests); | ||
| 40 | } | ||
| 41 | |||
| 42 | no Moose; | ||
| 43 | 1; | ||
| 44 | |||
| 45 | __END__ |