diff -Nru libtest-class-perl-0.47/Build.PL libtest-class-perl-0.50/Build.PL --- libtest-class-perl-0.47/Build.PL 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/Build.PL 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -use Module::Build 0.4004; # test_requires - -use strict; -use warnings; - -use Test::Builder; - -# 0.99 broke test_out with qr// -my $tb_v = Test::Builder->VERSION eq '0.99' ? '1.001002' : '0.78'; - -my $build = Module::Build->new( - module_name => 'Test::Class', - license => 'perl', - configure_requires => { - 'Module::Build' => '0.4004', - }, - requires => { - 'perl' => '5.008001', - 'Attribute::Handlers' => '0.77', - 'MRO::Compat' => '0.11', - 'Storable' => '2.04', - 'Test::Simple' => '1.001002', - 'Test::Builder' => $tb_v, - 'Test::Builder::Tester' => '1.02', - 'Carp' => '0', - 'File::Find' => '0', - 'File::Spec' => '0', - 'constant' => '0', - 'strict' => '0', - 'warnings' => '0', - }, - test_requires => { - 'Test::Exception' => '0.25', - 'IO::File' => '1.09', - 'Test::More' => '0.78', - 'Fcntl' => '0', - 'Test' => '0', - 'base' => '0', - 'overload' => '0', - }, - meta_merge => { - resources => { - repository => 'http://github.com/adrianh/test-class/', - }, - }, - create_makefile_pl => 'traditional', - create_readme => 1, -); -$build->create_build_script; diff -Nru libtest-class-perl-0.47/Changes libtest-class-perl-0.50/Changes --- libtest-class-perl-0.47/Changes 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/Changes 2015-06-07 00:07:24.000000000 +0000 @@ -1,5 +1,19 @@ Changes for Perl extension Test-Class +0.50 [2015-06-07] + - add links to Ovid's tutorial series on Test::Class (Tim Vroom, PR#19) + - add links to Test::Class::Most, Test::Class::Moose (Tim Vroom, PR#20) + - list some distributions that use Test::Class in their test suite (Tim + Vroom, PR#21) + - update documentation about running individual tests (Matthew Horsfall, + PR#22) + - fix some tests to work with the new Test::Stream (Chad Granum, PR#27) + - switch packaging to ExtUtils::MakeMaker + +0.48 [2014-11-06] + - replace a few bare evals with more modern alternatives + +0.47 [2014-09-26] - fixes for Test::More 1.301001_* series (PR#17, PR#18, Chad Granum) 0.46 [2014-07-06] diff -Nru libtest-class-perl-0.47/debian/changelog libtest-class-perl-0.50/debian/changelog --- libtest-class-perl-0.47/debian/changelog 2014-09-27 13:25:29.000000000 +0000 +++ libtest-class-perl-0.50/debian/changelog 2016-05-01 19:57:15.000000000 +0000 @@ -1,3 +1,25 @@ +libtest-class-perl (0.50-1) unstable; urgency=medium + + * Team upload + + [ gregor herrmann ] + * Add debian/upstream/metadata. + * Import upstream version 0.50. + * Update years of packaging copyright. + * Update (build) dependencies. + * Mark package as autopkgtest-able. + * Bump debhelper compatibility level to 9. + * Update Upstream-Contact in debian/copyright. + + [ Salvatore Bonaccorso ] + * debian/control: Use HTTPS transport protocol for Vcs-Git URI + + [ Florian Schlichting ] + * Run two tests without TEST_VERBOSE to avoid failures, see RT#114112 + * Declare compliance with Debian Policy 3.9.8 + + -- Florian Schlichting Sun, 01 May 2016 21:35:07 +0200 + libtest-class-perl (0.47-1) unstable; urgency=medium [ Salvatore Bonaccorso ] diff -Nru libtest-class-perl-0.47/debian/compat libtest-class-perl-0.50/debian/compat --- libtest-class-perl-0.47/debian/compat 2014-09-27 13:25:29.000000000 +0000 +++ libtest-class-perl-0.50/debian/compat 2016-05-01 19:06:59.000000000 +0000 @@ -1 +1 @@ -8 +9 diff -Nru libtest-class-perl-0.47/debian/control libtest-class-perl-0.50/debian/control --- libtest-class-perl-0.47/debian/control 2014-09-27 13:25:29.000000000 +0000 +++ libtest-class-perl-0.50/debian/control 2016-05-01 19:57:15.000000000 +0000 @@ -7,18 +7,19 @@ Ansgar Burchardt , Salvatore Bonaccorso Section: perl +Testsuite: autopkgtest-pkg-perl Priority: optional -Build-Depends: debhelper (>= 8), - libmodule-build-perl (>= 0.420400) +Build-Depends: debhelper (>= 9) Build-Depends-Indep: libcontextual-return-perl, libdevel-symdump-perl, libmro-compat-perl, + libmodule-runtime-perl, libtest-exception-perl, - perl (>= 5.19.6) | libtest-simple-perl (>= 1.001002), + libtry-tiny-perl, perl -Standards-Version: 3.9.6 +Standards-Version: 3.9.8 Vcs-Browser: https://anonscm.debian.org/cgit/pkg-perl/packages/libtest-class-perl.git -Vcs-Git: git://anonscm.debian.org/pkg-perl/packages/libtest-class-perl.git +Vcs-Git: https://anonscm.debian.org/git/pkg-perl/packages/libtest-class-perl.git Homepage: https://metacpan.org/release/Test-Class Package: libtest-class-perl @@ -27,7 +28,9 @@ ${perl:Depends}, libcontextual-return-perl, libmro-compat-perl, - libtest-exception-perl + libmodule-runtime-perl, + libtest-exception-perl, + libtry-tiny-perl Description: module for creating test classes in an xUnit style Test::Class is a Perl test harness for creating tests using the xUnit style inspired by Smalltalk. It is aimed at authors of Perl modules already using diff -Nru libtest-class-perl-0.47/debian/copyright libtest-class-perl-0.50/debian/copyright --- libtest-class-perl-0.47/debian/copyright 2014-09-27 13:25:29.000000000 +0000 +++ libtest-class-perl-0.50/debian/copyright 2016-05-01 19:06:59.000000000 +0000 @@ -1,8 +1,6 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Test-Class -Upstream-Contact: Adrian Howard , - Curtis "Ovid" Poe, , - Mark Morgan +Upstream-Contact: Karen Etheridge Source: https://metacpan.org/release/Test-Class Files: * @@ -19,7 +17,7 @@ 2007, 2008, Gunnar Wolf 2008, Ansgar Burchardt 2008, Damyan Ivanov - 2008, 2012, gregor herrmann + 2008-2015, gregor herrmann 2009-2014, Salvatore Bonaccorso 2010, Jonathan Yu License: Artistic or GPL-1+ diff -Nru libtest-class-perl-0.47/debian/patches/series libtest-class-perl-0.50/debian/patches/series --- libtest-class-perl-0.47/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ libtest-class-perl-0.50/debian/patches/series 2016-05-01 19:54:39.000000000 +0000 @@ -0,0 +1 @@ +test_non_verbose.patch diff -Nru libtest-class-perl-0.47/debian/patches/test_non_verbose.patch libtest-class-perl-0.50/debian/patches/test_non_verbose.patch --- libtest-class-perl-0.47/debian/patches/test_non_verbose.patch 1970-01-01 00:00:00.000000000 +0000 +++ libtest-class-perl-0.50/debian/patches/test_non_verbose.patch 2016-05-01 19:54:39.000000000 +0000 @@ -0,0 +1,25 @@ +Description: fix 2 test failures by running without TEST_VERBOSE + Fixed as a patch and not in d/rules so it can propagate into autopkgtest, too +Author: Florian Schlichting +Bug: https://rt.cpan.org/Public/Bug/Display.html?id=114112 + +--- a/t/skip2.t ++++ b/t/skip2.t +@@ -2,6 +2,7 @@ + + use strict; + use warnings; ++$ENV{TEST_VERBOSE}=0; + + # Override exit before Test::Class is loaded so the real override + # will be seen later. +--- a/t/teardown-when-test-dies.t ++++ b/t/teardown-when-test-dies.t +@@ -2,6 +2,7 @@ + + use strict; + use warnings; ++$ENV{TEST_VERBOSE}=0; + + my $line; + { diff -Nru libtest-class-perl-0.47/debian/upstream/metadata libtest-class-perl-0.50/debian/upstream/metadata --- libtest-class-perl-0.47/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ libtest-class-perl-0.50/debian/upstream/metadata 2016-05-01 19:06:59.000000000 +0000 @@ -0,0 +1,6 @@ +--- +Archive: CPAN +Contact: Adrian Howard , Curtis "Ovid" Poe, , + Mark Morgan . +Name: Test-Class +Repository: http://github.com/adrianh/test-class/ diff -Nru libtest-class-perl-0.47/lib/Test/Class/Load.pm libtest-class-perl-0.50/lib/Test/Class/Load.pm --- libtest-class-perl-0.47/lib/Test/Class/Load.pm 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/lib/Test/Class/Load.pm 2015-06-06 23:04:18.000000000 +0000 @@ -6,8 +6,9 @@ use Test::Class; use File::Find; use File::Spec; +use Module::Runtime 'require_module'; -our $VERSION = '0.47'; +our $VERSION = '0.50'; # Override to get your own filter sub is_test_class { @@ -30,13 +31,12 @@ # untaint that puppy! my ( $package ) = $_package =~ /^([[:word:]]+(?:::[[:word:]]+)*)$/; - + # Filter out bad classes (mainly this means things in .svn and similar) return unless defined $package; unshift @INC => $dir unless $Added_to_INC{ $dir }++; - eval "require $package"; ## no critic - die $@ if $@; + require_module($package); } sub import { @@ -69,7 +69,7 @@ =head1 VERSION -Version 0.41 +version 0.50 =head1 SYNOPSIS @@ -113,7 +113,7 @@ use Test::Class::Load 't/tests'; Test::Class->runtests; - + That will search through all files in the C directory and automatically load anything which ends in C<.pm>. You should only put test classes in those directories. If you have test classes in more than one directory, that's OK. Just list all of them in the import list. @@ -135,14 +135,14 @@ up and what others are not. You do this simply by subclassing C overriding the C method. You might want to do this to only load modules which inherit from C, or anything else -for that matter. +for that matter. =over 4 =item B $is_test_class = $class->is_test_class( $file, $directory ) - + Returns true if C<$file> in C<$directory> should be considered a test class and be loaded by L. The default filter simply returns true if C<$file> ends with C<.pm> =back @@ -162,7 +162,7 @@ # return unless it's a .pm (the default) return unless $class->SUPER::is_test_class( $file, $dir ); - + # and only allow .pm files with "Good" in their filename return $file =~ m{Good}; } @@ -172,7 +172,7 @@ =head2 CUSTOMIZING TEST RUNS One problem with this style of testing is that you run I of the tests every time you need to test something. If you want to run only one test class, it's problematic. The easy way to do this is to change your helper script by deleting the C call: - + #!/usr/bin/perl -T use strict; @@ -183,7 +183,7 @@ Then, just make sure that all of your test classes inherit from your own base class which runs the tests for you. It might looks something like this: package My::Test::Class; - + use strict; use warnings; @@ -198,7 +198,7 @@ prove -lv -It/tests Some::Test::Class You can even automate this by binding it to a key in C: - + noremap ,t :!prove -lv -It/tests % Then you can just type C<,t> ('comma', 'tee') and it will run the tests for your test class or the tests for your test script (if you're using a traditional C style script). diff -Nru libtest-class-perl-0.47/lib/Test/Class/MethodInfo.pm libtest-class-perl-0.50/lib/Test/Class/MethodInfo.pm --- libtest-class-perl-0.47/lib/Test/Class/MethodInfo.pm 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/lib/Test/Class/MethodInfo.pm 2015-06-06 23:04:18.000000000 +0000 @@ -4,7 +4,7 @@ package Test::Class::MethodInfo; use Carp; -our $VERSION = '0.47'; +our $VERSION = '0.50'; sub new { my ( $class, %param ) = @_; @@ -23,10 +23,10 @@ sub type { shift->{type} }; -sub num_tests { +sub num_tests { my ( $self, $n ) = @_; if ( defined $n ) { - croak "$n not valid number of tests" + croak "$n not valid number of tests" unless $self->is_num_tests($n); $self->{ num_tests } = $n; }; @@ -38,12 +38,12 @@ return $self->{ type } eq $type; }; -sub is_method_type { +sub is_method_type { my ( $self, $type ) = @_; return $type =~ m/^(startup|setup|test|teardown|shutdown)$/s; }; -sub is_num_tests { +sub is_num_tests { my ( $self, $num_tests ) = @_; return $num_tests =~ m/^(no_plan)|(\+?\d+)$/s; }; @@ -55,6 +55,10 @@ Test::Class::MethodInfo - the info associated with a test method +=head1 VERSION + +version 0.50 + =head1 SYNOPSIS # Secret internal class diff -Nru libtest-class-perl-0.47/lib/Test/Class.pm libtest-class-perl-0.50/lib/Test/Class.pm --- libtest-class-perl-0.47/lib/Test/Class.pm 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/lib/Test/Class.pm 2015-06-06 23:04:18.000000000 +0000 @@ -10,13 +10,14 @@ use Storable qw(dclone); use Test::Builder; use Test::Class::MethodInfo; +use Try::Tiny; -our $VERSION = '0.47'; +our $VERSION = '0.50'; my $Check_block_has_run; { no warnings 'void'; - CHECK { $Check_block_has_run = 1 }; + CHECK { $Check_block_has_run = 1 } } use constant NO_PLAN => "no_plan"; @@ -28,11 +29,11 @@ our $Current_method = undef; -sub current_method { $Current_method }; +sub current_method { $Current_method } my $Builder = Test::Builder->new; -sub builder { $Builder }; +sub builder { $Builder } my $Tests = {}; @@ -44,25 +45,25 @@ sub DESTROY { my $self = shift; delete $_Test{ $self }; -}; +} sub _test_info { my $self = shift; return ref($self) ? $_Test{$self} : $Tests; -}; +} sub _method_info { my ($self, $class, $method) = @_; return( _test_info($self)->{$class}->{$method} ); -}; +} sub _methods_of_class { my ( $self, $class ) = @_; - my $test_info = _test_info($self) + my $test_info = _test_info($self) or die "Test::Class internals seem confused. Did you override " . "new() in a sub-class or via multiple inheritance?\n"; return values %{ $test_info->{$class} }; -}; +} sub _parse_attribute_args { my $args = shift || ''; @@ -76,10 +77,10 @@ $type = $arg; } else { die 'bad attribute args'; - }; - }; + } + } return( $type, $num_tests ); -}; +} sub _is_public_method { my ($class, $name) = @_; @@ -100,16 +101,16 @@ my $name = *{$symbol}{NAME}; warn "overriding public method $name with a test method in $class\n" if _is_public_method( $class, $name ); - eval { $class->add_testinfo($name, _parse_attribute_args($args)) } - || warn "bad test definition '$args' in $class->$name\n"; - }; -}; + eval { $class->add_testinfo($name, _parse_attribute_args($args)) } + || warn "bad test definition '$args' in $class->$name\n"; + } +} sub Tests : ATTR(CODE,RAWDATA) { my ($class, $symbol, $code_ref, $attr, $args) = @_; $args ||= 'no_plan'; Test( $class, $symbol, $code_ref, $attr, $args ); -}; +} sub add_testinfo { my($class, $name, $type, $num_tests) = @_; @@ -132,16 +133,16 @@ my $self = bless {%$proto, @_}, $class; $_Test{$self} = dclone($Tests); return($self); -}; +} sub _get_methods { my ( $self, @types ) = @_; my $test_class = _class_of( $self ); - + my $test_method_regexp = $ENV{ TEST_METHOD } || '.*'; my $method_regexp = eval { qr/\A$test_method_regexp\z/ }; die "TEST_METHOD ($test_method_regexp) is not a valid regexp: $@" if $@; - + my %methods = (); foreach my $class ( @{mro::get_linear_isa( $test_class )} ) { FILTER: @@ -158,16 +159,16 @@ foreach my $type ( @types ) { if ( $info->is_type( $type ) ) { - $methods{ $name } = 1 + $methods{ $name } = 1 unless $type eq TEST && $name !~ $method_regexp; } - }; - }; - }; + } + } + } my @methods = sort keys %methods; return @methods; -}; +} sub _num_expected_tests { my $self = shift; @@ -176,9 +177,9 @@ }; my @test_methods = _get_methods($self, TEST); return 0 unless @test_methods; - my @startup_shutdown_methods = + my @startup_shutdown_methods = _get_methods($self, STARTUP, SHUTDOWN); - my $num_startup_shutdown_methods = + my $num_startup_shutdown_methods = _total_num_tests($self, @startup_shutdown_methods); return(NO_PLAN) if $num_startup_shutdown_methods eq NO_PLAN; my @fixture_methods = _get_methods($self, SETUP, TEARDOWN); @@ -187,7 +188,7 @@ my $num_tests = _total_num_tests($self, @test_methods); return(NO_PLAN) if $num_tests eq NO_PLAN; return($num_startup_shutdown_methods + $num_tests + @test_methods * $num_fixture_tests); -}; +} sub expected_tests { my $total = 0; @@ -201,10 +202,10 @@ } else { $test = 'undef' unless defined $test; croak "$test is not a Test::Class or an integer"; - }; - }; + } + } return $total; -}; +} sub _total_num_tests { my ($self, @methods) = @_; @@ -218,10 +219,10 @@ return(NO_PLAN) if ($num_tests eq NO_PLAN); $total_num_tests += $num_tests; last unless $num_tests =~ m/^\+/ - }; - }; + } + } return($total_num_tests); -}; +} sub _has_no_tests { my ( $self, $method ) = @_; @@ -240,10 +241,10 @@ my $current_test = $Builder->current_test; return(1) if $start_test == $current_test; my @results = ($Builder->summary)[$start_test .. $current_test-1]; - foreach my $result (@results) { return(0) unless $result }; + foreach my $result (@results) { return(0) unless $result } return(1); } -}; +} sub _exception_failure { my ($self, $method, $exception, $tests) = @_; @@ -255,13 +256,13 @@ chomp $exception; $Builder->ok(0, "$message died ($exception)"); _threw_exception( $self, $method => 1 ); -}; +} my %threw_exception; sub _threw_exception { my ( $self, $method, $optional_value) = @_; my $class = ref( $self ); - $threw_exception{ $class }{ $method } = $optional_value + $threw_exception{ $class }{ $method } = $optional_value if defined $optional_value; return $threw_exception{ $class }{ $method }; } @@ -279,22 +280,24 @@ unless ( defined($description) ) { $description = $self->current_method; $description =~ tr/_/ /; - }; + } my $is_ok = $original_ok->($builder, $test, $description); unless ( $is_ok ) { my $class = ref $self; $Builder->diag( " (in $class->$method)" ); - }; + } return $is_ok; }; - $skip_reason = eval {$self->$method}; + + my $exception; + $skip_reason = try { $self->$method } catch { $exception = $_; undef }; $skip_reason = $method unless $skip_reason; - my $exception = $@; + my $num_done = $Builder->current_test - $num_start; my $num_expected = _total_num_tests($self, $method); $num_expected = $num_done if $num_expected eq NO_PLAN; if ($num_done == $num_expected) { - _exception_failure($self, $method, $exception, $tests) + _exception_failure($self, $method, $exception, $tests) if $exception; } elsif ($num_done > $num_expected) { my $class = ref $self; @@ -312,11 +315,11 @@ } else { $Builder->skip( $skip_reason ); } - }; - }; - }; + } + } + } return(_all_ok_from($self, $num_start)); -}; +} sub fail_if_returned_early { 0 } @@ -328,8 +331,8 @@ $Builder->no_plan; } else { $Builder->expected_tests($num_tests); - }; -}; + } +} my %SKIP_THIS_CLASS = (); @@ -337,13 +340,13 @@ my $class = shift; $SKIP_THIS_CLASS{ $class } = shift if @_; return $SKIP_THIS_CLASS{ $class }; -}; +} sub _isa_class { my ( $class, $object_or_class ) = @_; return unless defined $object_or_class; return if $object_or_class eq 'Contextual::Return::Value'; - return eval { + return eval { $object_or_class->isa( $class ) and $object_or_class->can( 'runtests' ) }; } @@ -351,16 +354,16 @@ sub _test_classes { my $class = shift; return( @{mro::get_isarev($class)}, $class ); -}; +} sub runtests { - die "Test::Class was loaded too late (after the CHECK block was run). See 'A NOTE ON LOADING TEST CLASSES' in perldoc Test::Class for more details\n" + die "Test::Class was loaded too late (after the CHECK block was run), or you may have redefined a test_ sub. See 'A NOTE ON LOADING TEST CLASSES' in perldoc Test::Class for more details\n" unless $Check_block_has_run; my @tests = @_; if (@tests == 1 && !ref($tests[0])) { my $base_class = shift @tests; @tests = _test_classes( $base_class ); - }; + } my $all_passed = 1; TEST_OBJECT: foreach my $t (@tests) { # SHOULD ALSO ALLOW NO_PLAN @@ -379,11 +382,11 @@ my $method_passed = _run_method($t, $method, \@tests); $all_passed = 0 unless $method_passed; next TEST_OBJECT unless $method_passed; - }; + } my $class = ref($t); my @setup = _get_methods($t, SETUP); my @teardown = _get_methods($t, TEARDOWN); - foreach my $test ( @test_methods ) { + foreach my $test ( @test_methods ) { local $Current_method = $test; $Builder->diag("\n$class->$test") if $ENV{TEST_VERBOSE}; my @methods_to_run = (@setup, $test, @teardown); @@ -395,28 +398,28 @@ my $num_to_skip = _total_num_tests($t, @methods_to_run); $Builder->skip( "$method died" ) for ( 1 .. $num_to_skip ); last; - }; - }; - }; + } + } + } foreach my $method (_get_methods($t, SHUTDOWN)) { _show_header($t, @tests) unless _has_no_tests($t, $method); $all_passed = 0 unless _run_method($t, $method, \@tests); } } - + } } return($all_passed); -}; +} sub _find_calling_test_class { my $level = 0; while (my $class = caller(++$level)) { next if $class eq __PACKAGE__; return $class if _isa_class( __PACKAGE__, $class ); - }; + } return(undef); -}; +} sub num_method_tests { my ($self, $method, $n) = @_; @@ -426,23 +429,23 @@ or croak "$method is not a test method of class $class"; $info->num_tests($n) if defined($n); return( $info->num_tests ); -}; +} sub num_tests { my $self = shift; croak "num_tests need to be called within a test method" unless defined $Current_method; return( $self->num_method_tests( $Current_method, @_ ) ); -}; +} sub BAILOUT { my ($self, $reason) = @_; $Builder->BAILOUT($reason); -}; +} sub _last_test_if_exiting_immediately { $Builder->expected_tests || $Builder->current_test+1 -}; +} sub FAIL_ALL { my ($self, $reason) = @_; @@ -452,13 +455,13 @@ my $num_failed = $Builder->can("history") ? $Builder->history->fail_count : grep( !$_, $Builder->summary ); exit( $num_failed < 254 ? $num_failed : 254 ); -}; +} -sub SKIP_ALL { +sub SKIP_ALL { my ($self, $reason) = @_; $Builder->skip_all( $reason ) unless $Builder->has_plan; my $last_test = _last_test_if_exiting_immediately(); - $Builder->skip( $reason ) + $Builder->skip( $reason ) until $Builder->current_test >= $last_test; exit(0); } @@ -481,24 +484,28 @@ Test::Class - Easily create test classes in an xUnit/JUnit style +=head1 VERSION + +version 0.50 + =head1 SYNOPSIS package Example::Test; use base qw(Test::Class); use Test::More; - # setup methods are run before every test method. + # setup methods are run before every test method. sub make_fixture : Test(setup) { my $array = [1, 2]; shift->{test_array} = $array; - }; + } # a test method that runs 1 test sub test_push : Test { my $array = shift->{test_array}; push @$array, 3; is_deeply($array, [1, 2, 3], 'push worked'); - }; + } # a test method that runs 4 tests sub test_pop : Test(4) { @@ -507,13 +514,13 @@ is(pop @$array, 1, 'pop = 1'); is_deeply($array, [], 'array empty'); is(pop @$array, undef, 'pop = undef'); - }; + } # teardown methods are run after every test method. sub teardown : Test(teardown) { my $array = shift->{test_array}; diag("array = (@$array) after test(s)"); - }; + } later in a nearby .t file @@ -537,7 +544,7 @@ =head1 DESCRIPTION -Test::Class provides a simple way of creating classes and objects to test your code in an xUnit style. +Test::Class provides a simple way of creating classes and objects to test your code in an xUnit style. Built using L, it was designed to work with other Test::Builder based modules (L, L, L, etc.). @@ -556,7 +563,7 @@ While xUnit frameworks are traditionally associated with unit testing they are also useful in the creation of functional/acceptance tests. -Test::Class is (yet another) implementation of xUnit style testing in Perl. +Test::Class is (yet another) implementation of xUnit style testing in Perl. =head2 Why you should use Test::Class @@ -578,11 +585,11 @@ =item * -You do not have to learn a new set of new test APIs and can continue using ok(), like(), etc. from L and friends. +You do not have to learn a new set of new test APIs and can continue using ok(), like(), etc. from L and friends. =item * -Skipping tests and todo tests are supported. +Skipping tests and todo tests are supported. =item * @@ -651,64 +658,64 @@ sub subtraction : Test { is( 2-1, 1, 'subtraction works' ); - }; + } -This declares the C method as a test method that runs one test. +This declares the C method as a test method that runs one test. If your test method runs more than one test, you should put the number of tests in brackets like this: sub addition : Test(2) { is(10 + 20, 30, 'addition works'); is(20 + 10, 30, ' both ways'); - }; + } If you don't know the number of tests at compile time you can use C like this. sub check_class : Test(no_plan) { my $objects = shift->{objects}; isa_ok($_, "Object") foreach @$objects; - }; + } or use the :Tests attribute, which acts just like C<:Test> but defaults to C if no number is given: sub check_class : Tests { my $objects = shift->{objects}; isa_ok($_, "Object") foreach @$objects; - }; + } =head2 2) Setup and teardown methods Setup and teardown methods are run before and after every test. For example: - sub before : Test(setup) { diag("running before test") }; - sub after : Test(teardown) { diag("running after test") }; + sub before : Test(setup) { diag("running before test") } + sub after : Test(teardown) { diag("running after test") } You can use setup and teardown methods to create common objects used by all of your test methods (a test I) and store them in your Test::Class object, treating it as a hash. For example: sub pig : Test(setup) { my $self = shift; $self->{test_pig} = Pig->new; - }; + } sub born_hungry : Test { my $pig = shift->{test_pig}; is($pig->hungry, 'pigs are born hungry'); - }; + } sub eats : Test(3) { my $pig = shift->{test_pig}; ok( $pig->feed, 'pig fed okay'); ok(! $pig->hungry, 'fed pig not hungry'); ok(! $pig->feed, 'cannot feed full pig'); - }; + } You can also declare setup and teardown methods as running tests. For example you could check that the test pig survives each test method by doing: sub pig_alive : Test(teardown => 1) { my $pig = shift->{test_pig}; ok($pig->alive, 'pig survived tests' ); - }; + } =head2 3) Startup and shutdown methods @@ -719,18 +726,18 @@ sub db_connect : Test(startup) { shift->{dbi} = DBI->connect; - }; + } sub db_disconnect : Test(shutdown) { shift->{dbi}->disconnect; - }; + } Just like setup and teardown methods you can pass an optional number of tests to startup and shutdown methods. For example: sub example : Test(startup => 1) { ok(1, 'a startup method with one test'); - }; - + } + If you want to run an unknown number of tests within your startup method, you need to say e.g. sub example : Test(startup => no_plan) { @@ -740,7 +747,7 @@ as the : Tests attribute behaves exactly like : Test in this context. -If a startup method has a failing test or throws an exception then all other tests for the current test object are ignored. +If a startup method has a failing test or throws an exception then all other tests for the current test object are ignored. =head1 RUNNING TESTS @@ -751,16 +758,16 @@ runs all of the test methods in every loaded test class. This allows you to easily load multiple test classes in a *.t file and run them all. #! /usr/bin/perl - + # load all the test classes I want to run use Foo::Test; use Foo::Bar::Test; use Foo::Fribble::Test; use Foo::Ni::Test; - + # and run them all Test::Class->runtests; - + You can use L to automatically load all the test classes in a given set of directories. If you need finer control you can create individual test objects with L. For example to just run the tests in the test class C you can do: @@ -774,7 +781,7 @@ # runs all the tests in $o1 and $o2 $o1->runtests($o2); -Since, by definition, the base Test::Class has no tests you could also have written: +Since, by definition, the base Test::Class has no tests, you could also have written: my $o1 = Example::Test->new; my $o2 = Another::Test->new; @@ -802,16 +809,16 @@ If you prefer to write your test plan explicitly you can use L to find out the number of tests a class/object is expected to run. -Since L will not output a test plan if one has already been set the previous example can be written as: +Since L will not output a test plan if one has already been set, the previous example can be written as: plan tests => Test::Class->expected_tests(+2); Test::Class->runtests; ok(Example->new->foo, 'a test not in the test class'); ok(Example->new->bar, 'ditto'); -I Test objects are just normal perl objects. Test classes are just normal perl classes. Setup, test and teardown methods are just normal methods. You are completely free to have other methods in your class that are called from your test methods, or have object specific C and C methods. +I Test objects are just normal perl objects. Test classes are just normal perl classes. Setup, test and teardown methods are just normal methods. You are completely free to have other methods in your class that are called from your test methods, or have object specific C and C methods. -In particular you can override the new() method to pass parameters to your test object, or re-define the number of tests a method will run. See L for an example. +In particular you can override the new() method to pass parameters to your test object, or re-define the number of tests a method will run. See L for an example. =head1 TEST DESCRIPTIONS @@ -819,13 +826,13 @@ The test functions you import from L and other L based modules usually take an optional third argument that specifies the test description, for example: is $something, $something_else, 'a description of my test'; - + If you do not supply a test description, and the test function does not supply its own default, then Test::Class will use the name of the currently running test method, replacing all "_" characters with spaces so: sub one_plus_one_is_two : Test { is 1+1, 2; } - + will result in: ok 1 - one plus one is two @@ -872,7 +879,7 @@ sub _check_new { my $self = shift; isa_ok(Object->new, "Object") or $self->BAILOUT('new fails!'); - }; + } The leading C<_> will force the above method to run first - allowing the entire suite to be aborted before any other test methods run. @@ -885,7 +892,7 @@ my $object = Object->new; isa_ok( $object, "Object" ) or die "could not create object\n"; ok( $object->open, "open worked" ); - }; + } will produce the following if the first test failed: @@ -899,7 +906,7 @@ # at /Users/adrianh/Desktop/foo.pl line 19. # (in MyTest->test_object) -This can considerably simplify testing code that throws exceptions. +This can considerably simplify testing code that throws exceptions. Rather than having to explicitly check that the code exited normally (e.g. with L) the test will fail automatically - without aborting the other test methods. For example contrast: @@ -913,13 +920,13 @@ sub read_file : Test { is(read_file('test.txt'), "content", 'test file read'); - }; - + } + If more than one test remains after an exception then the first one is failed, and the remaining ones are skipped. If the setup method of a test method dies, then all of the remaining setup and shutdown methods are also skipped. -Since startup methods will usually be creating state needed by all the other test methods an exception within a startup method will prevent all other test methods of that class running. +Since startup methods will usually be creating state needed by all the other test methods, an exception within a startup method will prevent all other test methods of that class running. =head1 RETURNING EARLY @@ -952,7 +959,7 @@ ok($pig->takeoff, 'takeoff') or return("takeoff failed"); ok( $pig->altitude > 0, 'Pig is airborne' ); ok( $pig->airspeed > 0, ' and moving' ); - }; + } If you run this test in an environment where Cnew> worked and the takeoff method existed, but failed when ran, you would get: @@ -962,7 +969,7 @@ ok 4 # skip takeoff failed ok 5 # skip takeoff failed -You can also skip tests just as you do in Test::More or Test::Builder - see L for more information. +You can also skip tests just as you do in Test::More or Test::Builder - see L for more information. I if you want to skip tests in a method with C tests then you have to explicitly skip the tests in the method - since Test::Class cannot determine how many tests (if any) should be skipped: @@ -973,8 +980,8 @@ isa_ok($_, "Object") foreach (@$objects); } else { $self->builder->skip("no objects to test"); - }; - }; + } + } Another way of overcoming this problem is to explicitly set the number of tests for the method at run time using L or L<"num_tests">. @@ -987,7 +994,7 @@ sub live_test : Test { local $TODO = "live currently unimplemented"; ok(Object->live, "object live"); - }; + } See L for more information. @@ -1000,26 +1007,26 @@ use base qw(Test::Class); use Test::More; - sub testing_class { "Pig" }; - sub new_args { (-age => 3) }; + sub testing_class { "Pig" } + sub new_args { (-age => 3) } sub setup : Test(setup) { my $self = shift; my $class = $self->testing_class; my @args = $self->new_args; $self->{pig} = $class->new( @args ); - }; + } sub _creation : Test { my $self = shift; - isa_ok($self->{pig}, $self->testing_class) + isa_ok($self->{pig}, $self->testing_class) or $self->FAIL_ALL('Pig->new failed'); - }; + } sub check_fields : Test { - my $pig = shift->{pig}; + my $pig = shift->{pig} is($pig->age, 3, "age accessed"); - }; + } Next consider C a subclass of C where you can give your pig a name. @@ -1029,33 +1036,33 @@ use base qw(Pig::Test); use Test::More; - sub testing_class { "NamedPig" }; - sub new_args { (shift->SUPER::new_args, -name => 'Porky') }; + sub testing_class { "NamedPig" } + sub new_args { (shift->SUPER::new_args, -name => 'Porky') } Now we need to test the name method. We could write another test method, but we also have the option of extending the existing C method. sub check_fields : Test(2) { my $self = shift; - $self->SUPER::check_fields; + $self->SUPER::check_fields; is($self->{pig}->name, 'Porky', 'name accessed'); - }; + } While the above works, the total number of tests for the method is dependent on the number of tests in its C. If we add a test to Ccheck_fields> we will also have to update the number of tests of Ccheck_fields>. -Test::Class allows us to state explicitly that we are adding tests to an existing method by using the C<+> prefix. Since we are adding a single test to C it can be rewritten as: +Test::Class allows us to state explicitly that we are adding tests to an existing method by using the C<+> prefix. Since we are adding a single test to C, it can be rewritten as: sub check_fields : Test(+1) { my $self = shift; $self->SUPER::check_fields; is($self->{pig}->name, 'Porky', 'name accessed'); - }; + } With the above definition you can add tests to C in C without affecting C. =head1 RUNNING INDIVIDUAL TESTS -B The exact mechanism for running individual tests is likely to change in the future. +B The exact mechanism for running individual tests is likely to change in the future. Sometimes you just want to run a single test. Commenting out other tests or writing code to skip them can be a hassle, so you can specify the C environment variable. The value is expected to be a valid regular expression and, if present, only runs test methods whose names match the regular expression. Startup, setup, teardown and shutdown tests will still be run. @@ -1065,7 +1072,7 @@ #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = 'customer_profile'; Test::Class->runtests; @@ -1073,7 +1080,7 @@ #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = '.*customer.*'; Test::Class->runtests; @@ -1081,7 +1088,7 @@ #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = 'C++'; Test::Class->runtests; @@ -1117,11 +1124,11 @@ This can be problematic if you want to dynamically load Test::Class modules. Basically while: require $some_test_class; - + will break, doing: - BEGIN { require $some_test_class }; - + BEGIN { require $some_test_class } + will work just fine. For more information on CHECK blocks see L. If you still can't arrange for your classes to be loaded at runtime, you could use an alternative mechanism for adding your tests: @@ -1133,6 +1140,8 @@ See the L method for more details. +Additionally, if you've forgotten to enable warnings and have two test subs called the same thing, you will get the same error. + =head1 GENERAL FILTERING OF TESTS The use of $ENV{TEST_METHOD} to run just a subset of tests is useful, but @@ -1166,7 +1175,7 @@ my ( $test_class, $test_method ) = @_; return $test_method =~ $MYTEST_METHOD; - }; + } Test::Class->add_filter( $filter ); sub t_filtered : Test( 1 ) { @@ -1186,28 +1195,28 @@ =item B # test methods - sub method_name : Test { ... }; - sub method_name : Test(N) { ... }; + sub method_name : Test { ... } + sub method_name : Test(N) { ... } # setup methods - sub method_name : Test(setup) { ... }; - sub method_name : Test(setup => N) { ... }; + sub method_name : Test(setup) { ... } + sub method_name : Test(setup => N) { ... } # teardown methods - sub method_name : Test(teardown) { ... }; - sub method_name : Test(teardown => N) { ... }; + sub method_name : Test(teardown) { ... } + sub method_name : Test(teardown => N) { ... } # startup methods - sub method_name : Test(startup) { ... }; - sub method_name : Test(startup => N) { ... }; + sub method_name : Test(startup) { ... } + sub method_name : Test(startup => N) { ... } # shutdown methods - sub method_name : Test(shutdown) { ... }; - sub method_name : Test(shutdown => N) { ... }; + sub method_name : Test(shutdown) { ... } + sub method_name : Test(shutdown => N) { ... } Marks a startup, setup, test, teardown or shutdown method. See L for information on how to run methods declared with the C attribute. -N specifies the number of tests the method runs. +N specifies the number of tests the method runs. =over 4 @@ -1225,20 +1234,20 @@ =back -If N is not specified it defaults to C<1> for test methods, and C<0> for startup, setup, teardown and shutdown methods. +If N is not specified it defaults to C<1> for test methods, and C<0> for startup, setup, teardown and shutdown methods. You can change the number of tests that a method runs using L or L. =item B - sub method_name : Tests { ... }; - sub method_name : Tests(N) { ... }; + sub method_name : Tests { ... } + sub method_name : Tests(N) { ... } Acts just like the C<:Test> attribute, except that if the number of tests is not specified it defaults to C. So the following are equivalent: - sub silly1 :Test( no_plan ) { ok(1) foreach (1 .. rand 5) }; - sub silly2 :Tests { ok(1) foreach (1 .. rand 5) }; + sub silly1 :Test( no_plan ) { ok(1) foreach (1 .. rand 5) } + sub silly2 :Tests { ok(1) foreach (1 .. rand 5) } =item B @@ -1246,23 +1255,23 @@ $Tests = CLASS->new(KEY => VAL ...) $Tests2 = $Tests->new(KEY => VAL ...) -Creates a new test object (blessed hashref) containing the specified key/value pairs. +Creates a new test object (blessed hashref) containing the specified key/value pairs. If called as an object method the existing object's key/value pairs are copied into the new object. Any key/value pairs passed to C override those in the original object if duplicates occur. -Since the test object is passed to every test method as it runs it is a convenient place to store test fixtures. For example: +Since the test object is passed to every test method as it runs, it is a convenient place to store test fixtures. For example: sub make_fixture : Test(setup) { my $self = shift; $self->{object} = Object->new(); $self->{dbh} = Mock::DBI->new(-type => normal); - }; + } sub test_open : Test { my $self = shift; my ($o, $dbh) = ($self->{object}, $self->{dbh}); ok($o->open($dbh), "opened ok"); - }; + } See L for an example of overriding C. @@ -1305,10 +1314,10 @@ C is used to run test classes. At its most basic doing: $test->runtests - -will run the test methods of the test object $test, unless C<< $test->SKIP_CLASS >> returns a true value. -Unless you have already specified a test plan using Test::Builder (or Test::More, et al) C will set the test plan just before the first method that runs a test is executed. +will run the test methods of the test object $test, unless C<< $test->SKIP_CLASS >> returns a true value. + +Unless you have already specified a test plan using Test::Builder (or Test::More, et al) C will set the test plan just before the first method that runs a test is executed. If the environment variable C is set C will display the name of each test method before it runs like this: @@ -1317,7 +1326,7 @@ # My::Test::Class->another_test ok 2 - bar -Just like L, C can take an optional list of test object/classes and integers. All of the test object/classes are run. Any integers are added to the total number of tests shown in the test header output by C. +Just like L, C can take an optional list of test object/classes and integers. All of the test object/classes are run. Any integers are added to the total number of tests shown in the test header output by C. For example, you can run all the tests in test classes A, B and C, plus one additional normal test by doing: @@ -1328,14 +1337,14 @@ #! /usr/bin/perl # Test all the Foo stuff - + use Foo::Test; use Foo::Bar::Test; use Foo::Ni::Test; - + # run all the Foo*Test modules we just loaded Test::Class->runtests; - + =item B @@ -1347,7 +1356,7 @@ You can override the default on a class-by-class basis by supplying a new value to SKIP_CLASS. For example if you have an abstract base class that should not run just add the following to your module: My::Abstract::Test->SKIP_CLASS( 1 ); - + This will not affect any sub-classes of C which will run as normal. If the true value returned by SKIP_CLASS is anything other than "1" then a skip test is output using this value as the skip message. For example: @@ -1366,8 +1375,8 @@ sub My::Postgres::Test::SKIP_CLASS { $ENV{POSTGRES_HOME} ? 0 : '$POSTGRES_HOME needs to be set' - }; - + } + =back =head2 Fetching and setting a method's test number @@ -1388,7 +1397,7 @@ If the method is extending the number of tests run by the method in a superclass then $n should have a C<+> prefix. -When called as a class method any change to the expected number of tests applies to all future test objects. Existing test objects are unaffected. +When called as a class method any change to the expected number of tests applies to all future test objects. Existing test objects are unaffected. When called as an object method any change to the expected number of tests applies to that object alone. @@ -1396,7 +1405,7 @@ For example, the following test class will run a different number of tests depending on the number of objects supplied. - package Object::Test; + package Object::Test; use base qw(Test::Class); use Test::More; @@ -1406,12 +1415,12 @@ my $num_objects = @{$self->{objects}}; $self->num_method_tests('test_objects', $num_objects); return($self); - }; + } sub test_objects : Tests { my $self = shift; ok($_->open, "opened $_") foreach @{$self->{objects}}; - }; + } ... # This runs two tests Object::Test->new(objects => [$o1, $o2]); @@ -1431,7 +1440,7 @@ $self->SUPER::test_objects; my @bad_objects = grep {! $_->read_only} (@{$self->{objects}}); ok(@bad_objects == 0, "all objects read only"); - }; + } ... # This runs three tests Special::Object::Test->new(objects => [$o1, $o2]); @@ -1455,7 +1464,7 @@ my @files = <*.txt>; $self->num_tests(scalar(@files)); ok(-r $_, "$_ readable") foreach (@files); - }; + } Setting the number of expected tests at run time, rather than just having a C test method, allows L to display appropriate diagnostic messages if the method runs a different number of tests. @@ -1476,14 +1485,14 @@ my $self = shift; my ($o, $dbh) = ($self->{object}, $self->{dbh}); $self->builder->ok($o->close($dbh), "closed ok"); - }; + } =item B $method_name = $Tests->current_method $method_name = CLASS->current_method -Returns the name of the test method currently being executed by L, or C if L has not been called. +Returns the name of the test method currently being executed by L, or C if L has not been called. The method name is also available in the setup and teardown methods that run before and after the test method. This can be useful in producing diagnostic messages, for example: @@ -1491,7 +1500,7 @@ my $self = shift; my $m = $self->current_method; ok($self->invarient_ok, "class okay after $m"); - }; + } @@ -1520,10 +1529,10 @@ sub _test_new : Test(3) { my $self = shift; - isa_ok(Object->new, "Object") + isa_ok(Object->new, "Object") || $self->FAIL_ALL('cannot create Objects'); ... - }; + } @@ -1540,8 +1549,8 @@ sub _darwin_only : Test(setup) { my $self = shift; - $self->SKIP_ALL("darwin only") unless $^O eq "darwin"; - }; + $self->SKIP_ALL("darwin only") unless $^O eq "darwin"; + } =item B @@ -1587,14 +1596,14 @@ sub foo : Test(2) { ok($foo->method1); ok($foo->method2); - }; + } The second test I run if the first one fails. You can emulate the JUnit way of doing it by throwing an explicit exception on test failure: sub foo : Test(2) { ok($foo->method1) or die "method1 failed"; ok($foo->method2); - }; + } The exception will be caught by Test::Class and the other test automatically failed. @@ -1602,7 +1611,7 @@ Test::Class corresponds to TestCase in JUnit. -In Test::Class setup, test and teardown methods are marked explicitly using the L attribute. Since we need to know the total number of tests to provide a test plan for L we also state how many tests each method runs. +In Test::Class setup, test and teardown methods are marked explicitly using the L attribute. Since we need to know the total number of tests to provide a test plan for L, we also state how many tests each method runs. Unlike JUnit you can have multiple setup/teardown methods in a class. @@ -1610,11 +1619,11 @@ Test::Class also does the work that would be done by TestSuite in JUnit. -Since the methods are marked with attributes Test::Class knows what is and isn't a test method. This allows it to run all the test methods without having the developer create a suite manually, or use reflection to dynamically determine the test methods by name. See the L method for more details. +Since the methods are marked with attributes, Test::Class knows what is and isn't a test method. This allows it to run all the test methods without having the developer create a suite manually, or use reflection to dynamically determine the test methods by name. See the L method for more details. The running order of the test methods is fixed in Test::Class. Methods are executed in alphabetical order. -Unlike JUnit, Test::Class currently does not allow you to run individual test methods. +To run individual test methods, see L. =item B @@ -1629,7 +1638,7 @@ =head1 OTHER MODULES FOR XUNIT TESTING IN PERL -In addition to Test::Class there are two other distributions for xUnit testing in perl. Both have a longer history than Test::Class and might be more suitable for your needs. +In addition to Test::Class there are two other distributions for xUnit testing in perl. Both have a longer history than Test::Class and might be more suitable for your needs. I am biased since I wrote Test::Class - so please read the following with appropriate levels of scepticism. If you think I have misrepresented the modules please let me know. @@ -1639,9 +1648,9 @@ A very simple unit testing framework. If you are looking for a lightweight single module solution this might be for you. -The advantage of L is that it is simple! Just one module with a smallish API to learn. +The advantage of L is that it is simple! Just one module with a smallish API to learn. -Of course this is also the disadvantage. +Of course this is also the disadvantage. It's not class based so you cannot create testing classes to reuse and extend. @@ -1653,9 +1662,9 @@ It is class based so you can easily reuse your test classes and extend by subclassing. You get a nice flexible framework you can tweak to your heart's content. If you can run Tk you also get a graphical test runner. -However, Test::Unit is not based on L. You cannot easily move Test::Builder based test functions into Test::Unit based classes. You have to learn another test assertion API. +However, Test::Unit is not based on L. You cannot easily move Test::Builder based test functions into Test::Unit based classes. You have to learn another test assertion API. -Test::Unit implements it's own testing framework separate from L. You can retrofit *.t scripts as unit tests, and output test results in the format that L expects, but things like L and L are not supported. +Test::Unit implements it's own testing framework separate from L. You can retrofit *.t scripts as unit tests, and output test results in the format that L expects, but things like L and L are not supported. =back @@ -1693,7 +1702,7 @@ This is yet another implementation of the ideas from Kent Beck's Testing Framework paper L. -Thanks to +Thanks to Adam Kennedy, agianni, Alexander D'Archangel, @@ -1702,7 +1711,7 @@ Ask Bjorn Hansen, Chris Dolan, Chris Williams, -Corion, +Corion, Cosimo Streppone, Daniel Berger, Dave Evans, @@ -1710,7 +1719,7 @@ David Cantrell, David Wheeler, Diab Jerius, -Emil Jansson, +Emil Jansson, Gunnar Wolf, Hai Pham, Hynek, @@ -1718,7 +1727,7 @@ Jeff Deifik, Jim Brandt, Jochen Stenzel, -Johan Lindstrom, +Johan Lindstrom, John West, Jonathan R. Warden, Joshua ben Jore, @@ -1733,11 +1742,11 @@ Mathieu Sauve-Frankel, Matt Trout, Matt Williamson, -Michael G Schwern, -Murat Uenalan, +Michael G Schwern, +Murat Uenalan, Naveed Massjouni, Nicholas Clark, -Ovid, +Ovid, Piers Cawley, Rob Kinyon, Sam Raymer, @@ -1746,12 +1755,12 @@ Steve Kirkup, Stray Toaster, Ted Carnahan, -Terrence Brannon, +Terrence Brannon, Todd W, Tom Metro, -Tony Bowden, +Tony Bowden, Tony Edwardson, -William McKee, +William McKee, various anonymous folk and all the fine people on perl-qa for their feedback, patches, suggestions and nagging. This module wouldn't be possible without the excellent L. Thanks to chromatic and Michael G Schwern for creating such a useful module. @@ -1771,6 +1780,14 @@ Simple way to load "Test::Class" classes automatically. +=item L + +Test::Class with additional conveniences to reduce need for some boilerplate code. Also makes L testing functions available. + +=item L + +Testing framework allows you to write your tests in Moose and test Moose and non-Moose code. It offers reporting, extensibility, test inheritance, parallel testing and more. + =item L Delicious links on Test::Class. @@ -1787,6 +1804,22 @@ Includes the article "Test-Driven Development in Perl" by Piers Cawley that uses Test::Class. +=item Test::Class Tutorial series written by Curtis "Ovid" Poe + +=over 4 + +=item * L + +=item * L + +=item * L + +=item * L + +=item * L + +=back + =item L Support module for building test libraries. @@ -1817,7 +1850,7 @@ =over 4 -L, Bricolage (L), L, L, L, L, L, L, L, L, L, L, L, L, and L +L, L, Bricolage (L), L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, and L =back @@ -1827,11 +1860,11 @@ =item L -Perl unit testing framework closely modeled on JUnit. +Perl unit testing framework closely modeled on JUnit. =item L -A very simple unit testing framework. +A very simple unit testing framework. =back diff -Nru libtest-class-perl-0.47/Makefile.PL libtest-class-perl-0.50/Makefile.PL --- libtest-class-perl-0.47/Makefile.PL 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/Makefile.PL 2015-06-06 23:58:40.000000000 +0000 @@ -1,26 +1,143 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.4210 +use strict; +use warnings; require 5.008001; use ExtUtils::MakeMaker; -WriteMakefile -( - 'NAME' => 'Test::Class', - 'VERSION_FROM' => 'lib/Test/Class.pm', - 'PREREQ_PM' => { - 'Attribute::Handlers' => '0.77', - 'Carp' => '0', - 'File::Find' => '0', - 'File::Spec' => '0', - 'MRO::Compat' => '0.11', - 'Storable' => '2.04', - 'Test::Builder' => '0.78', - 'Test::Builder::Tester' => '1.02', - 'Test::Simple' => '1.001002', - 'constant' => '0', - 'strict' => '0', - 'warnings' => '0' - }, - 'INSTALLDIRS' => 'site', - 'EXE_FILES' => [], - 'PL_FILES' => {} -) -; + +my $developer = -f '.gitignore'; +ExtUtils::MakeMaker->VERSION(6.98) if $developer; + +my %WriteMakefileArgs = ( + NAME => 'Test::Class', + VERSION_FROM => 'lib/Test/Class.pm', + ABSTRACT_FROM => 'lib/Test/Class.pm', + AUTHOR => 'Adrian Howard , Curtis "Ovid" Poe, , Mark Morgan ', + LICENSE => 'perl_5', + + META_MERGE => { + 'meta-spec' => { version => 2 }, + dynamic_config => 1, + resources => { + repository => { + url => 'https://github.com/adrianh/test-class.git', + web => 'https://github.com/adrianh/test-class', + type => 'git', + }, + bugtracker => { + mailto => 'bug-Test-Class@rt.cpan.org', + web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Class', + }, + }, + x_contributors => [ # manually added, from git shortlog -e -s -n + 'Adrian Howard ', + 'Karen Etheridge ', + 'Curtis Poe ', + 'makk384 ', + 'Ricardo Signes ', + 'Alexandr Ciornii ', + 'Tim Vroom ', + 'Matthew Horsfall ', + 'Michael G. Schwern ', + 'Chad Granum ', + 'Peter Sergeant ', + 'Sam Kington ', + 'Klaus S. Madsen ', + 'Zefram ', + 'Kent Fredric ', + ], + x_MailingList => 'http://lists.perl.org/list/perl-qa.html', + x_IRC => 'irc://irc.perl.org/#perl-qa', + }, + + META_ADD => { + prereqs => { + configure => { + requires => { + 'ExtUtils::MakeMaker' => '0', + }, + }, + runtime => { + requires => { + 'perl' => '5.008001', + 'Attribute::Handlers' => '0.77', + 'MRO::Compat' => '0.11', + 'Storable' => '2.04', + 'Test::Simple' => '0.78', + 'Test::Builder' => '0.78', + 'Test::Builder::Tester' => '1.02', + 'Carp' => '0', + 'File::Find' => '0', + 'File::Spec' => '0', + 'constant' => '0', + 'strict' => '0', + 'warnings' => '0', + 'Try::Tiny' => '0', + 'Module::Runtime' => '0', + }, + }, + test => { + requires => { + 'Test::Exception' => '0.25', + 'IO::File' => '1.09', + 'Test::More' => '0.78', + 'Fcntl' => '0', + 'Test' => '0', + 'base' => '0', + 'overload' => '0', + }, + }, + }, + }, +); + +my $eumm_version = eval $ExtUtils::MakeMaker::VERSION; + +for (qw(configure build test runtime)) { + my $key = $_ eq 'runtime' ? 'PREREQ_PM' : uc $_.'_REQUIRES'; + next unless exists $WriteMakefileArgs{META_ADD}{prereqs}{$_} + or exists $WriteMakefileArgs{$key}; + my $r = $WriteMakefileArgs{$key} = { + %{$WriteMakefileArgs{META_ADD}{prereqs}{$_}{requires} || {}}, + %{delete $WriteMakefileArgs{$key} || {}}, + }; + defined $r->{$_} or delete $r->{$_} for keys %$r; +} + +# dynamic prereqs get added here. + +# 0.99 broke test_out with qr// +$WriteMakefileArgs{PREREQ_PM}{'Test::Builder'} = '1.001002' + if eval { require Test::Builder; Test::Builder->VERSION eq '0.99' }; + +$WriteMakefileArgs{MIN_PERL_VERSION} = delete $WriteMakefileArgs{PREREQ_PM}{perl} || 0; + +die 'attention developer: you need to do a sane meta merge here!' + if keys %{$WriteMakefileArgs{BUILD_REQUIRES}}; + +$WriteMakefileArgs{BUILD_REQUIRES} = { + %{$WriteMakefileArgs{BUILD_REQUIRES} || {}}, + %{delete $WriteMakefileArgs{TEST_REQUIRES}} +} if $eumm_version < 6.63_03; + +$WriteMakefileArgs{PREREQ_PM} = { + %{$WriteMakefileArgs{PREREQ_PM}}, + %{delete $WriteMakefileArgs{BUILD_REQUIRES}} +} if $eumm_version < 6.55_01; + +delete $WriteMakefileArgs{CONFIGURE_REQUIRES} + if $eumm_version < 6.51_03; + +delete $WriteMakefileArgs{MIN_PERL_VERSION} + if $eumm_version < 6.48; + +delete @WriteMakefileArgs{qw(META_ADD META_MERGE)} + if $eumm_version < 6.46; + +delete $WriteMakefileArgs{LICENSE} + if $eumm_version < 6.31; + +WriteMakefile(%WriteMakefileArgs); + +use Config; +system("$Config{bin}/pod2text $WriteMakefileArgs{VERSION_FROM} > README") + if $developer + and (not -e 'README' or (stat('README'))[9] < (stat($WriteMakefileArgs{VERSION_FROM}))[9]); diff -Nru libtest-class-perl-0.47/MANIFEST libtest-class-perl-0.50/MANIFEST --- libtest-class-perl-0.47/MANIFEST 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/MANIFEST 2015-06-07 00:07:59.000000000 +0000 @@ -1,9 +1,12 @@ -Build.PL Changes lib/Test/Class.pm lib/Test/Class/Load.pm lib/Test/Class/MethodInfo.pm -MANIFEST This list of files +Makefile.PL +MANIFEST +META.json +META.yml +README t/00-load.t t/20-load-classes.t t/21-load-subclassed.t @@ -78,7 +81,3 @@ xt/pmv.t xt/pod.t xt/spelling.t -Makefile.PL -README -META.yml -META.json diff -Nru libtest-class-perl-0.47/META.json libtest-class-perl-0.50/META.json --- libtest-class-perl-0.47/META.json 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/META.json 2015-06-07 00:08:03.000000000 +0000 @@ -1,10 +1,10 @@ { "abstract" : "Easily create test classes in an xUnit/JUnit style", "author" : [ - "Adrian Howard , Curtis \"Ovid\" Poe, , Mark Morgan ." + "Adrian Howard , Curtis \"Ovid\" Poe, , Mark Morgan " ], "dynamic_config" : 1, - "generated_by" : "Module::Build version 0.421", + "generated_by" : "ExtUtils::MakeMaker version 7.052, CPAN::Meta::Converter version 2.150004", "license" : [ "perl_5" ], @@ -13,10 +13,19 @@ "version" : "2" }, "name" : "Test-Class", + "no_index" : { + "directory" : [ + "t", + "inc" + ] + }, "prereqs" : { + "build" : { + "requires" : {} + }, "configure" : { "requires" : { - "Module::Build" : "0.4004" + "ExtUtils::MakeMaker" : "0" } }, "runtime" : { @@ -26,10 +35,12 @@ "File::Find" : "0", "File::Spec" : "0", "MRO::Compat" : "0.11", + "Module::Runtime" : "0", "Storable" : "2.04", "Test::Builder" : "0.78", "Test::Builder::Tester" : "1.02", - "Test::Simple" : "1.001002", + "Test::Simple" : "0.78", + "Try::Tiny" : "0", "constant" : "0", "perl" : "5.008001", "strict" : "0", @@ -48,28 +59,38 @@ } } }, - "provides" : { - "Test::Class" : { - "file" : "lib/Test/Class.pm", - "version" : "0.47" - }, - "Test::Class::Load" : { - "file" : "lib/Test/Class/Load.pm", - "version" : "0.47" - }, - "Test::Class::MethodInfo" : { - "file" : "lib/Test/Class/MethodInfo.pm", - "version" : "0.47" - } - }, "release_status" : "stable", "resources" : { - "license" : [ - "http://dev.perl.org/licenses/" - ], + "bugtracker" : { + "mailto" : "bug-Test-Class@rt.cpan.org", + "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Class" + }, "repository" : { - "url" : "http://github.com/adrianh/test-class/" + "type" : "git", + "url" : "https://github.com/adrianh/test-class.git", + "web" : "https://github.com/adrianh/test-class" } }, - "version" : "0.47" + "version" : "0.50", + "x_IRC" : "irc://irc.perl.org/#perl-qa", + "x_MailingList" : "http://lists.perl.org/list/perl-qa.html", + "x_contributors" : [ + "Adrian Howard ", + "Karen Etheridge ", + "Curtis Poe ", + "makk384 ", + "Ricardo Signes ", + "Alexandr Ciornii ", + "Tim Vroom ", + "Matthew Horsfall ", + "Michael G. Schwern ", + "Chad Granum ", + "Peter Sergeant ", + "Sam Kington ", + "Klaus S. Madsen ", + "Zefram ", + "Kent Fredric " + ], + "x_serialization_backend" : "JSON::PP version 2.27300" } + diff -Nru libtest-class-perl-0.47/META.yml libtest-class-perl-0.50/META.yml --- libtest-class-perl-0.47/META.yml 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/META.yml 2015-06-07 00:08:03.000000000 +0000 @@ -1,7 +1,7 @@ --- abstract: 'Easily create test classes in an xUnit/JUnit style' author: - - 'Adrian Howard , Curtis "Ovid" Poe, , Mark Morgan .' + - 'Adrian Howard , Curtis "Ovid" Poe, , Mark Morgan ' build_requires: Fcntl: '0' IO::File: '1.09' @@ -11,39 +11,55 @@ base: '0' overload: '0' configure_requires: - Module::Build: '0.4004' + ExtUtils::MakeMaker: '0' dynamic_config: 1 -generated_by: 'Module::Build version 0.421, CPAN::Meta::Converter version 2.142060' +generated_by: 'ExtUtils::MakeMaker version 7.052, CPAN::Meta::Converter version 2.150004' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Test-Class -provides: - Test::Class: - file: lib/Test/Class.pm - version: '0.47' - Test::Class::Load: - file: lib/Test/Class/Load.pm - version: '0.47' - Test::Class::MethodInfo: - file: lib/Test/Class/MethodInfo.pm - version: '0.47' +no_index: + directory: + - t + - inc requires: Attribute::Handlers: '0.77' Carp: '0' File::Find: '0' File::Spec: '0' MRO::Compat: '0.11' + Module::Runtime: '0' Storable: '2.04' Test::Builder: '0.78' Test::Builder::Tester: '1.02' - Test::Simple: '1.001002' + Test::Simple: '0.78' + Try::Tiny: '0' constant: '0' perl: '5.008001' strict: '0' warnings: '0' resources: - license: http://dev.perl.org/licenses/ - repository: http://github.com/adrianh/test-class/ -version: '0.47' + bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Test-Class + repository: https://github.com/adrianh/test-class.git +version: '0.50' +x_IRC: irc://irc.perl.org/#perl-qa +x_MailingList: http://lists.perl.org/list/perl-qa.html +x_contributors: + - 'Adrian Howard ' + - 'Karen Etheridge ' + - 'Curtis Poe ' + - 'makk384 ' + - 'Ricardo Signes ' + - 'Alexandr Ciornii ' + - 'Tim Vroom ' + - 'Matthew Horsfall ' + - 'Michael G. Schwern ' + - 'Chad Granum ' + - 'Peter Sergeant ' + - 'Sam Kington ' + - 'Klaus S. Madsen ' + - 'Zefram ' + - 'Kent Fredric ' +x_serialization_backend: 'CPAN::Meta::YAML version 0.016' + diff -Nru libtest-class-perl-0.47/README libtest-class-perl-0.50/README --- libtest-class-perl-0.47/README 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/README 2015-06-06 23:47:11.000000000 +0000 @@ -1,23 +1,26 @@ NAME Test::Class - Easily create test classes in an xUnit/JUnit style +VERSION + version 0.50 + SYNOPSIS package Example::Test; use base qw(Test::Class); use Test::More; - # setup methods are run before every test method. + # setup methods are run before every test method. sub make_fixture : Test(setup) { my $array = [1, 2]; shift->{test_array} = $array; - }; + } # a test method that runs 1 test sub test_push : Test { my $array = shift->{test_array}; push @$array, 3; is_deeply($array, [1, 2, 3], 'push worked'); - }; + } # a test method that runs 4 tests sub test_pop : Test(4) { @@ -26,13 +29,13 @@ is(pop @$array, 1, 'pop = 1'); is_deeply($array, [], 'array empty'); is(pop @$array, undef, 'pop = undef'); - }; + } # teardown methods are run after every test method. sub teardown : Test(teardown) { my $array = shift->{test_array}; diag("array = (@$array) after test(s)"); - }; + } later in a nearby .t file @@ -70,13 +73,13 @@ A brief history lesson In 1994 Kent Beck wrote a testing framework for Smalltalk called SUnit. It was popular. You can read a copy of his original paper at - http://www.xprogramming.com/testfram.htm. + . Later Kent Beck and Erich Gamma created JUnit for testing Java - http://www.junit.org/. It was popular too. + . It was popular too. Now there are xUnit frameworks for every language from Ada to XSLT. You - can find a list at http://www.xprogramming.com/software.htm. + can find a list at . While xUnit frameworks are traditionally associated with unit testing they are also useful in the creation of functional/acceptance tests. @@ -163,9 +166,9 @@ sub subtraction : Test { is( 2-1, 1, 'subtraction works' ); - }; + } - This declares the `subtraction' method as a test method that runs one + This declares the "subtraction" method as a test method that runs one test. If your test method runs more than one test, you should put the number @@ -174,30 +177,30 @@ sub addition : Test(2) { is(10 + 20, 30, 'addition works'); is(20 + 10, 30, ' both ways'); - }; + } If you don't know the number of tests at compile time you can use - `no_plan' like this. + "no_plan" like this. sub check_class : Test(no_plan) { my $objects = shift->{objects}; isa_ok($_, "Object") foreach @$objects; - }; + } - or use the :Tests attribute, which acts just like `:Test' but defaults - to `no_plan' if no number is given: + or use the :Tests attribute, which acts just like ":Test" but defaults + to "no_plan" if no number is given: sub check_class : Tests { my $objects = shift->{objects}; isa_ok($_, "Object") foreach @$objects; - }; + } 2) Setup and teardown methods Setup and teardown methods are run before and after every test. For example: - sub before : Test(setup) { diag("running before test") }; - sub after : Test(teardown) { diag("running after test") }; + sub before : Test(setup) { diag("running before test") } + sub after : Test(teardown) { diag("running after test") } You can use setup and teardown methods to create common objects used by all of your test methods (a test *fixture*) and store them in your @@ -206,19 +209,19 @@ sub pig : Test(setup) { my $self = shift; $self->{test_pig} = Pig->new; - }; + } sub born_hungry : Test { my $pig = shift->{test_pig}; is($pig->hungry, 'pigs are born hungry'); - }; + } sub eats : Test(3) { my $pig = shift->{test_pig}; ok( $pig->feed, 'pig fed okay'); ok(! $pig->hungry, 'fed pig not hungry'); ok(! $pig->feed, 'cannot feed full pig'); - }; + } You can also declare setup and teardown methods as running tests. For example you could check that the test pig survives each test method by @@ -227,7 +230,7 @@ sub pig_alive : Test(teardown => 1) { my $pig = shift->{test_pig}; ok($pig->alive, 'pig survived tests' ); - }; + } 3) Startup and shutdown methods Startup and shutdown methods are like setup and teardown methods for the @@ -241,19 +244,19 @@ sub db_connect : Test(startup) { shift->{dbi} = DBI->connect; - }; + } sub db_disconnect : Test(shutdown) { shift->{dbi}->disconnect; - }; + } Just like setup and teardown methods you can pass an optional number of tests to startup and shutdown methods. For example: sub example : Test(startup => 1) { ok(1, 'a startup method with one test'); - }; - + } + If you want to run an unknown number of tests within your startup method, you need to say e.g. @@ -276,22 +279,22 @@ to easily load multiple test classes in a *.t file and run them all. #! /usr/bin/perl - + # load all the test classes I want to run use Foo::Test; use Foo::Bar::Test; use Foo::Fribble::Test; use Foo::Ni::Test; - + # and run them all Test::Class->runtests; - + You can use Test::Class::Load to automatically load all the test classes in a given set of directories. If you need finer control you can create individual test objects with new(). For example to just run the tests in the test class - `Foo::Bar::Test' you can do: + "Foo::Bar::Test" you can do: Example::Test->new->runtests @@ -302,7 +305,7 @@ # runs all the tests in $o1 and $o2 $o1->runtests($o2); - Since, by definition, the base Test::Class has no tests you could also + Since, by definition, the base Test::Class has no tests, you could also have written: my $o1 = Example::Test->new; @@ -341,8 +344,8 @@ expected_tests() to find out the number of tests a class/object is expected to run. - Since runtests() will not output a test plan if one has already been set - the previous example can be written as: + Since runtests() will not output a test plan if one has already been + set, the previous example can be written as: plan tests => Test::Class->expected_tests(+2); Test::Class->runtests; @@ -353,7 +356,7 @@ just normal perl classes. Setup, test and teardown methods are just normal methods. You are completely free to have other methods in your class that are called from your test methods, or have object specific - `new' and `DESTROY' methods. + "new" and "DESTROY" methods. In particular you can override the new() method to pass parameters to your test object, or re-define the number of tests a method will run. @@ -365,7 +368,7 @@ test description, for example: is $something, $something_else, 'a description of my test'; - + If you do not supply a test description, and the test function does not supply its own default, then Test::Class will use the name of the currently running test method, replacing all "_" characters with spaces @@ -374,7 +377,7 @@ sub one_plus_one_is_two : Test { is 1+1, 2; } - + will result in: ok 1 - one plus one is two @@ -401,9 +404,9 @@ sub _check_new { my $self = shift; isa_ok(Object->new, "Object") or $self->BAILOUT('new fails!'); - }; + } - The leading `_' will force the above method to run first - allowing the + The leading "_" will force the above method to run first - allowing the entire suite to be aborted before any other test methods run. HANDLING EXCEPTIONS @@ -415,7 +418,7 @@ my $object = Object->new; isa_ok( $object, "Object" ) or die "could not create object\n"; ok( $object->open, "open worked" ); - }; + } will produce the following if the first test failed: @@ -432,8 +435,9 @@ This can considerably simplify testing code that throws exceptions. Rather than having to explicitly check that the code exited normally - (e.g. with Test::Exception) the test will fail automatically - without - aborting the other test methods. For example contrast: + (e.g. with "lives_ok" in Test::Exception) the test will fail + automatically - without aborting the other test methods. For example + contrast: use Test::Exception; @@ -445,8 +449,8 @@ sub read_file : Test { is(read_file('test.txt'), "content", 'test file read'); - }; - + } + If more than one test remains after an exception then the first one is failed, and the remaining ones are skipped. @@ -454,15 +458,15 @@ setup and shutdown methods are also skipped. Since startup methods will usually be creating state needed by all the - other test methods an exception within a startup method will prevent all - other test methods of that class running. + other test methods, an exception within a startup method will prevent + all other test methods of that class running. RETURNING EARLY If a test method returns before it has run all of its tests, by default the missing tests are deemed to have been skipped; see "Skipped Tests" for more information. - However, if the class's `fail_if_returned_early' method returns true, + However, if the class's "fail_if_returned_early" method returns true, then the missing tests will be deemed to have failed. For example, package MyClass; @@ -491,9 +495,9 @@ ok($pig->takeoff, 'takeoff') or return("takeoff failed"); ok( $pig->altitude > 0, 'Pig is airborne' ); ok( $pig->airspeed > 0, ' and moving' ); - }; + } - If you run this test in an environment where `Pig->new' worked and the + If you run this test in an environment where "Pig->new" worked and the takeoff method existed, but failed when ran, you would get: ok 1 - The object isa Pig @@ -503,9 +507,9 @@ ok 5 # skip takeoff failed You can also skip tests just as you do in Test::More or Test::Builder - - see Test::More for more information. + see "Conditional tests" in Test::More for more information. - *Note:* if you want to skip tests in a method with `no_plan' tests then + *Note:* if you want to skip tests in a method with "no_plan" tests then you have to explicitly skip the tests in the method - since Test::Class cannot determine how many tests (if any) should be skipped: @@ -516,8 +520,8 @@ isa_ok($_, "Object") foreach (@$objects); } else { $self->builder->skip("no objects to test"); - }; - }; + } + } Another way of overcoming this problem is to explicitly set the number of tests for the method at run time using num_method_tests() or @@ -528,85 +532,85 @@ TO DO TESTS You can create todo tests just as you do in Test::More and Test::Builder - using the `$TODO' variable. For example: + using the $TODO variable. For example: sub live_test : Test { local $TODO = "live currently unimplemented"; ok(Object->live, "object live"); - }; + } - See Test::Harness for more information. + See "Todo tests" in Test::Harness for more information. EXTENDING TEST CLASSES BY INHERITANCE You can extend test methods by inheritance in the usual way. For example - consider the following test class for a `Pig' object. + consider the following test class for a "Pig" object. package Pig::Test; use base qw(Test::Class); use Test::More; - sub testing_class { "Pig" }; - sub new_args { (-age => 3) }; + sub testing_class { "Pig" } + sub new_args { (-age => 3) } sub setup : Test(setup) { my $self = shift; my $class = $self->testing_class; my @args = $self->new_args; $self->{pig} = $class->new( @args ); - }; + } sub _creation : Test { my $self = shift; - isa_ok($self->{pig}, $self->testing_class) + isa_ok($self->{pig}, $self->testing_class) or $self->FAIL_ALL('Pig->new failed'); - }; + } sub check_fields : Test { - my $pig = shift->{pig}; + my $pig = shift->{pig} is($pig->age, 3, "age accessed"); - }; + } - Next consider `NamedPig' a subclass of `Pig' where you can give your pig + Next consider "NamedPig" a subclass of "Pig" where you can give your pig a name. - We want to make sure that all the tests for the `Pig' object still work - for `NamedPig'. We can do this by subclassing `Pig::Test' and overriding - the `testing_class' and `new_args' methods. + We want to make sure that all the tests for the "Pig" object still work + for "NamedPig". We can do this by subclassing "Pig::Test" and overriding + the "testing_class" and "new_args" methods. package NamedPig::Test; use base qw(Pig::Test); use Test::More; - sub testing_class { "NamedPig" }; - sub new_args { (shift->SUPER::new_args, -name => 'Porky') }; + sub testing_class { "NamedPig" } + sub new_args { (shift->SUPER::new_args, -name => 'Porky') } Now we need to test the name method. We could write another test method, - but we also have the option of extending the existing `check_fields' + but we also have the option of extending the existing "check_fields" method. sub check_fields : Test(2) { my $self = shift; - $self->SUPER::check_fields; + $self->SUPER::check_fields; is($self->{pig}->name, 'Porky', 'name accessed'); - }; + } While the above works, the total number of tests for the method is - dependent on the number of tests in its `SUPER::check_fields'. If we add - a test to `Pig::Test->check_fields' we will also have to update the - number of tests of `NamedPig::test->check_fields'. + dependent on the number of tests in its "SUPER::check_fields". If we add + a test to "Pig::Test->check_fields" we will also have to update the + number of tests of "NamedPig::test->check_fields". Test::Class allows us to state explicitly that we are adding tests to an - existing method by using the `+' prefix. Since we are adding a single - test to `check_fields' it can be rewritten as: + existing method by using the "+" prefix. Since we are adding a single + test to "check_fields", it can be rewritten as: sub check_fields : Test(+1) { my $self = shift; $self->SUPER::check_fields; is($self->{pig}->name, 'Porky', 'name accessed'); - }; + } - With the above definition you can add tests to `check_fields' in - `Pig::Test' without affecting `NamedPig::Test'. + With the above definition you can add tests to "check_fields" in + "Pig::Test" without affecting "NamedPig::Test". RUNNING INDIVIDUAL TESTS NOTE: The exact mechanism for running individual tests is likely to @@ -614,27 +618,27 @@ Sometimes you just want to run a single test. Commenting out other tests or writing code to skip them can be a hassle, so you can specify the - `TEST_METHOD' environment variable. The value is expected to be a valid + "TEST_METHOD" environment variable. The value is expected to be a valid regular expression and, if present, only runs test methods whose names match the regular expression. Startup, setup, teardown and shutdown tests will still be run. One easy way of doing this is by specifying the environment variable - *before* the `runtests' method is called. + *before* the "runtests" method is called. - Running a test named `customer_profile': + Running a test named "customer_profile": #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = 'customer_profile'; Test::Class->runtests; - Running all tests with `customer' in their name: + Running all tests with "customer" in their name: #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = '.*customer.*'; Test::Class->runtests; @@ -643,7 +647,7 @@ #! /usr/bin/perl use Example::Test; - + $ENV{TEST_METHOD} = 'C++'; Test::Class->runtests; @@ -656,8 +660,8 @@ You can, of course, organise your test modules as you wish. My personal preferences is: - * Name test classes with a suffix of `::Test' so the test class for - the `Foo::Bar' module would be `Foo::Bar::Test'. + * Name test classes with a suffix of "::Test" so the test class for + the "Foo::Bar" module would be "Foo::Bar::Test". * Place all test classes in t/lib. @@ -673,12 +677,13 @@ modules. Basically while: require $some_test_class; - + will break, doing: - BEGIN { require $some_test_class }; - - will work just fine. For more information on CHECK blocks see perlmod. + BEGIN { require $some_test_class } + + will work just fine. For more information on CHECK blocks see "BEGIN, + CHECK, INIT and END" in perlmod. If you still can't arrange for your classes to be loaded at runtime, you could use an alternative mechanism for adding your tests: @@ -690,6 +695,9 @@ See the add_testinfo method for more details. + Additionally, if you've forgotten to enable warnings and have two test + subs called the same thing, you will get the same error. + GENERAL FILTERING OF TESTS The use of $ENV{TEST_METHOD} to run just a subset of tests is useful, but sometimes it doesn't give the level of granularity that you desire. @@ -723,7 +731,7 @@ my ( $test_class, $test_method ) = @_; return $test_method =~ $MYTEST_METHOD; - }; + } Test::Class->add_filter( $filter ); sub t_filtered : Test( 1 ) { @@ -738,56 +746,56 @@ Creating and running tests Test # test methods - sub method_name : Test { ... }; - sub method_name : Test(N) { ... }; + sub method_name : Test { ... } + sub method_name : Test(N) { ... } # setup methods - sub method_name : Test(setup) { ... }; - sub method_name : Test(setup => N) { ... }; + sub method_name : Test(setup) { ... } + sub method_name : Test(setup => N) { ... } # teardown methods - sub method_name : Test(teardown) { ... }; - sub method_name : Test(teardown => N) { ... }; + sub method_name : Test(teardown) { ... } + sub method_name : Test(teardown => N) { ... } # startup methods - sub method_name : Test(startup) { ... }; - sub method_name : Test(startup => N) { ... }; + sub method_name : Test(startup) { ... } + sub method_name : Test(startup => N) { ... } # shutdown methods - sub method_name : Test(shutdown) { ... }; - sub method_name : Test(shutdown => N) { ... }; + sub method_name : Test(shutdown) { ... } + sub method_name : Test(shutdown => N) { ... } Marks a startup, setup, test, teardown or shutdown method. See runtests() for information on how to run methods declared with the - `Test' attribute. + "Test" attribute. N specifies the number of tests the method runs. * If N is an integer then the method should run exactly N tests. - * If N is an integer with a `+' prefix then the method is expected - to call its `SUPER::' method and extend it by running N + * If N is an integer with a "+" prefix then the method is expected + to call its "SUPER::" method and extend it by running N additional tests. - * If N is the string `no_plan' then the method can run an + * If N is the string "no_plan" then the method can run an arbitrary number of tests. - If N is not specified it defaults to `1' for test methods, and `0' - for startup, setup, teardown and shutdown methods. + If N is not specified it defaults to 1 for test methods, and 0 for + startup, setup, teardown and shutdown methods. You can change the number of tests that a method runs using num_method_tests() or num_tests(). Tests - sub method_name : Tests { ... }; - sub method_name : Tests(N) { ... }; + sub method_name : Tests { ... } + sub method_name : Tests(N) { ... } - Acts just like the `:Test' attribute, except that if the number of - tests is not specified it defaults to `no_plan'. So the following + Acts just like the ":Test" attribute, except that if the number of + tests is not specified it defaults to "no_plan". So the following are equivalent: - sub silly1 :Test( no_plan ) { ok(1) foreach (1 .. rand 5) }; - sub silly2 :Tests { ok(1) foreach (1 .. rand 5) }; + sub silly1 :Test( no_plan ) { ok(1) foreach (1 .. rand 5) } + sub silly2 :Tests { ok(1) foreach (1 .. rand 5) } new $Tests = CLASS->new(KEY => VAL ...) @@ -797,25 +805,25 @@ key/value pairs. If called as an object method the existing object's key/value pairs - are copied into the new object. Any key/value pairs passed to `new' + are copied into the new object. Any key/value pairs passed to "new" override those in the original object if duplicates occur. - Since the test object is passed to every test method as it runs it + Since the test object is passed to every test method as it runs, it is a convenient place to store test fixtures. For example: sub make_fixture : Test(setup) { my $self = shift; $self->{object} = Object->new(); $self->{dbh} = Mock::DBI->new(-type => normal); - }; + } sub test_open : Test { my $self = shift; my ($o, $dbh) = ($self->{object}, $self->{dbh}); ok($o->open($dbh), "opened ok"); - }; + } - See num_method_tests() for an example of overriding `new'. + See num_method_tests() for an example of overriding "new". expected_tests $n = $Tests->expected_tests @@ -827,20 +835,20 @@ specified class/object. This includes tests run by any setup and teardown methods. - Will return `no_plan' if the exact number of tests is undetermined + Will return "no_plan" if the exact number of tests is undetermined (i.e. if any setup, test or teardown method has an undetermined number of tests). - The `expected_tests' of an object after runtests() has been executed + The "expected_tests" of an object after runtests() has been executed will include any run time changes to the expected number of tests made by num_tests() or num_method_tests(). - `expected_tests' can also take an optional list of test objects, + "expected_tests" can also take an optional list of test objects, test classes and integers. In this case the result is the total number of expected tests for all the test/object classes (including the one the method was applied to) plus any integer values. - `expected_tests' is useful when you're integrating one or more test + "expected_tests" is useful when you're integrating one or more test classes into a more traditional test script, for example: use Test::More; @@ -858,18 +866,18 @@ $allok = $Tests->runtests(TEST, ...) $allok = CLASS->runtests(TEST, ...) - `runtests' is used to run test classes. At its most basic doing: + "runtests" is used to run test classes. At its most basic doing: $test->runtests - + will run the test methods of the test object $test, unless - `$test->SKIP_CLASS' returns a true value. + "$test->SKIP_CLASS" returns a true value. Unless you have already specified a test plan using Test::Builder - (or Test::More, et al) `runtests' will set the test plan just before + (or Test::More, et al) "runtests" will set the test plan just before the first method that runs a test is executed. - If the environment variable `TEST_VERBOSE' is set `runtests' will + If the environment variable "TEST_VERBOSE" is set "runtests" will display the name of each test method before it runs like this: # My::Test::Class->my_test @@ -877,10 +885,10 @@ # My::Test::Class->another_test ok 2 - bar - Just like expected_tests(), `runtests' can take an optional list of + Just like expected_tests(), "runtests" can take an optional list of test object/classes and integers. All of the test object/classes are run. Any integers are added to the total number of tests shown in - the test header output by `runtests'. + the test header output by "runtests". For example, you can run all the tests in test classes A, B and C, plus one additional normal test by doing: @@ -888,20 +896,20 @@ Test::Class->runtests(qw(A B C), +1); ok(1==1, 'non class test'); - Finally, if you call `runtests' on a test class without any + Finally, if you call "runtests" on a test class without any arguments it will run all of the test methods of that class, and all subclasses of that class. For example: #! /usr/bin/perl # Test all the Foo stuff - + use Foo::Test; use Foo::Bar::Test; use Foo::Ni::Test; - + # run all the Foo*Test modules we just loaded Test::Class->runtests; - + SKIP_CLASS $reason = CLASS->SKIP_CLASS; CLASS->SKIP_CLASS( $reason ); @@ -915,8 +923,8 @@ class that should not run just add the following to your module: My::Abstract::Test->SKIP_CLASS( 1 ); - - This will not affect any sub-classes of `My::Abstract::Test' which + + This will not affect any sub-classes of "My::Abstract::Test" which will run as normal. If the true value returned by SKIP_CLASS is anything other than "1" @@ -927,7 +935,7 @@ $ENV{POSTGRES_HOME} ? 0 : '$POSTGRES_HOME needs to be set' ); - will output something like this if `POSTGRES_HOME' is not set + will output something like this if "POSTGRES_HOME" is not set ... other tests ... ok 123 # skip My::Postgres::Test - $POSTGRES_HOME needs to be set @@ -939,8 +947,8 @@ sub My::Postgres::Test::SKIP_CLASS { $ENV{POSTGRES_HOME} ? 0 : '$POSTGRES_HOME needs to be set' - }; - + } + Fetching and setting a method's test number num_method_tests $n = $Tests->num_method_tests($method_name) @@ -952,10 +960,10 @@ to run. If the method has an undetermined number of tests then $n should be - the string `no_plan'. + the string "no_plan". If the method is extending the number of tests run by the method in - a superclass then $n should have a `+' prefix. + a superclass then $n should have a "+" prefix. When called as a class method any change to the expected number of tests applies to all future test objects. Existing test objects are @@ -964,14 +972,14 @@ When called as an object method any change to the expected number of tests applies to that object alone. - `num_method_tests' is useful when you need to set the expected + "num_method_tests" is useful when you need to set the expected number of tests at object creation time, rather than at compile time. For example, the following test class will run a different number of tests depending on the number of objects supplied. - package Object::Test; + package Object::Test; use base qw(Test::Class); use Test::More; @@ -981,12 +989,12 @@ my $num_objects = @{$self->{objects}}; $self->num_method_tests('test_objects', $num_objects); return($self); - }; + } sub test_objects : Tests { my $self = shift; ok($_->open, "opened $_") foreach @{$self->{objects}}; - }; + } ... # This runs two tests Object::Test->new(objects => [$o1, $o2]); @@ -997,11 +1005,11 @@ This allows better diagnostics from runtests(), Test::Builder and Test::Harness. - `num_method_tests' is a protected method and can only be called by + "num_method_tests" is a protected method and can only be called by subclasses of Test::Class. It fetches or sets the expected number of tests for the methods of the class it was *called in*, not the methods of the object/class it was *applied to*. This allows test - classes that use `num_method_tests' to be subclassed easily. + classes that use "num_method_tests" to be subclassed easily. For example, consider the creation of a subclass of Object::Test that ensures that all the opened objects are read-only: @@ -1015,13 +1023,13 @@ $self->SUPER::test_objects; my @bad_objects = grep {! $_->read_only} (@{$self->{objects}}); ok(@bad_objects == 0, "all objects read only"); - }; + } ... # This runs three tests Special::Object::Test->new(objects => [$o1, $o2]); - Since the call to `num_method_tests' in Object::Test only affects - the `test_objects' of Object::Test, the above works as you would + Since the call to "num_method_tests" in Object::Test only affects + the "test_objects" of Object::Test, the above works as you would expect. num_tests @@ -1041,10 +1049,10 @@ my @files = <*.txt>; $self->num_tests(scalar(@files)); ok(-r $_, "$_ readable") foreach (@files); - }; + } Setting the number of expected tests at run time, rather than just - having a `no_plan' test method, allows runtests() to display + having a "no_plan" test method, allows runtests() to display appropriate diagnostic messages if the method runs a different number of tests. @@ -1059,14 +1067,14 @@ my $self = shift; my ($o, $dbh) = ($self->{object}, $self->{dbh}); $self->builder->ok($o->close($dbh), "closed ok"); - }; + } current_method $method_name = $Tests->current_method $method_name = CLASS->current_method Returns the name of the test method currently being executed by - runtests(), or `undef' if runtests() has not been called. + runtests(), or "undef" if runtests() has not been called. The method name is also available in the setup and teardown methods that run before and after the test method. This can be useful in @@ -1076,7 +1084,7 @@ my $self = shift; my $m = $self->current_method; ok($self->invarient_ok, "class okay after $m"); - }; + } BAILOUT $Tests->BAILOUT($reason) @@ -1088,8 +1096,8 @@ $self->builder->BAILOUT - See Test::Builder for details. Any teardown and shutdown methods are - *not* run. + See "BAILOUT" in Test::Builder for details. Any teardown and + shutdown methods are *not* run. FAIL_ALL $Tests->FAIL_ALL($reason) @@ -1097,8 +1105,8 @@ Things are going so badly all the remaining tests in the current script should fail. Exits immediately with the number of tests - failed, or `254' if more than 254 tests were run. Any teardown - methods are *not* run. + failed, or 254 if more than 254 tests were run. Any teardown methods + are *not* run. This does not affect the running of any other test scripts invoked by Test::Harness. @@ -1108,17 +1116,17 @@ sub _test_new : Test(3) { my $self = shift; - isa_ok(Object->new, "Object") + isa_ok(Object->new, "Object") || $self->FAIL_ALL('cannot create Objects'); ... - }; + } SKIP_ALL $Tests->SKIP_ALL($reason) CLASS->SKIP_ALL($reason) Things are going so badly all the remaining tests in the current - script should be skipped. Exits immediately with `0' - teardown + script should be skipped. Exits immediately with 0 - teardown methods are *not* run. This does not affect the running of any other test scripts invoked @@ -1129,20 +1137,20 @@ sub _darwin_only : Test(setup) { my $self = shift; - $self->SKIP_ALL("darwin only") unless $^O eq "darwin"; - }; + $self->SKIP_ALL("darwin only") unless $^O eq "darwin"; + } add_testinfo CLASS->add_testinfo($name, $type, $num_tests) Chiefly for use by libraries like Test::Class::Sugar, which can't - use the `:Test(...)' interfaces make test methods. `add_testinfo' + use the ":Test(...)" interfaces make test methods. "add_testinfo" informs the class about a test method that has been defined without - a `Test', `Tests' or other attribute. + a "Test", "Tests" or other attribute. - `$name' is the name of the method, `$type' must be one of `startup', - `setup', `test', `teardown' or `shutdown', and `$num_tests' has the - same meaning as `N' in the description of the Test attribute. + $name is the name of the method, $type must be one of "startup", + "setup", "test", "teardown" or "shutdown", and $num_tests has the + same meaning as "N" in the description of the Test attribute. add_filter CLASS->add_filter($filter_coderef); @@ -1183,7 +1191,7 @@ sub foo : Test(2) { ok($foo->method1); ok($foo->method2); - }; + } The second test *will* run if the first one fails. You can emulate the JUnit way of doing it by throwing an explicit exception on test @@ -1192,7 +1200,7 @@ sub foo : Test(2) { ok($foo->method1) or die "method1 failed"; ok($foo->method2); - }; + } The exception will be caught by Test::Class and the other test automatically failed. @@ -1202,7 +1210,7 @@ In Test::Class setup, test and teardown methods are marked explicitly using the Test attribute. Since we need to know the total - number of tests to provide a test plan for Test::Harness we also + number of tests to provide a test plan for Test::Harness, we also state how many tests each method runs. Unlike JUnit you can have multiple setup/teardown methods in a @@ -1212,7 +1220,7 @@ Test::Class also does the work that would be done by TestSuite in JUnit. - Since the methods are marked with attributes Test::Class knows what + Since the methods are marked with attributes, Test::Class knows what is and isn't a test method. This allows it to run all the test methods without having the developer create a suite manually, or use reflection to dynamically determine the test methods by name. See @@ -1221,8 +1229,7 @@ The running order of the test methods is fixed in Test::Class. Methods are executed in alphabetical order. - Unlike JUnit, Test::Class currently does not allow you to run - individual test methods. + To run individual test methods, see "RUNNING INDIVIDUAL TESTS". Class TestRunner Test::Harness does the work of the TestRunner in JUnit. It collects @@ -1262,7 +1269,7 @@ new test assertion API. It does not support todo tests. Test::Unit - Test::Unit is a port of JUnit http://www.junit.org/ into perl. If + Test::Unit is a port of JUnit into perl. If you have used JUnit then the Test::Unit framework should be very familiar. @@ -1285,36 +1292,36 @@ If you find any bugs please let me know by e-mail at , or report the problem with - http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Class. + . COMMUNITY perl-qa If you are interested in testing using Perl I recommend you visit - http://qa.perl.org/ and join the excellent perl-qa mailing list. See - http://lists.perl.org/showlist.cgi?name=perl-qa for details on how to + and join the excellent perl-qa mailing list. See + for details on how to subscribe. perlmonks You can find users of Test::Class, including the module author, on - http://www.perlmonks.org/. Feel free to ask questions on Test::Class + . Feel free to ask questions on Test::Class there. CPAN::Forum The CPAN Forum is a web forum for discussing Perl's CPAN modules. The Test::Class forum can be found at - http://www.cpanforum.com/dist/Test-Class. + . TO DO If you think this module should do something that it doesn't (or does something that it shouldn't) please let me know. You can see my current to do list at - http://adrianh.tadalist.com/lists/public/4798, with an RSS feed of - changes at http://adrianh.tadalist.com/lists/feed_public/4798. + , with an RSS feed of + changes at . ACKNOWLEDGMENTS This is yet another implementation of the ideas from Kent Beck's Testing - Framework paper http://www.xprogramming.com/testfram.htm. + Framework paper . Thanks to Adam Kennedy, agianni, Alexander D'Archangel, Andrew Grangaard, Apocalypse, Ask Bjorn Hansen, Chris Dolan, Chris Williams, @@ -1340,13 +1347,22 @@ cpan.org>, Mark Morgan . If you use this module, and can spare the time please let us know or - rate it at http://cpanratings.perl.org/rate/?distribution=Test-Class. + rate it at . SEE ALSO Test::Class::Load Simple way to load "Test::Class" classes automatically. - http://del.icio.us/tag/Test::Class + Test::Class::Most + Test::Class with additional conveniences to reduce need for some + boilerplate code. Also makes Test::Most testing functions available. + + Test::Class::Moose + Testing framework allows you to write your tests in Moose and test + Moose and non-Moose code. It offers reporting, extensibility, test + inheritance, parallel testing and more. + + Delicious links on Test::Class. Perl Testing: A Developer's Notebook by Ian Langworth and chromatic @@ -1359,16 +1375,33 @@ Includes the article "Test-Driven Development in Perl" by Piers Cawley that uses Test::Class. + Test::Class Tutorial series written by Curtis "Ovid" Poe + + * + + * + + * + + * + + * + Test::Builder Support module for building test libraries. Test::Simple & Test::More Basic utilities for writing tests. - http://qa.perl.org/test-modules.html + Overview of some of the many testing modules available on CPAN. - http://del.icio.us/tag/perl+testing + Delicious links on perl testing. Test::Object @@ -1380,11 +1413,11 @@ The following modules use Test::Class as part of their test suite. You might want to look at them for usage examples: - Aspect, Bricolage (http://www.bricolage.cc/), Class::StorageFactory, - CGI::Application::Search, DBIx::Romani, Xmldoom, Object::Relational, - File::Random, Geography::JapanesePrefectures, Google::Adwords, - Merge::HashRef, PerlBuildSystem, Pixie, Yahoo::Marketing, and - XUL-Node + App-GitGot, Aspect, Bricolage (), CHI, + Cinnamon, Class::StorageFactory, CGI::Application::Search, + DBIx::Romani, Xmldoom, Object::Relational, File::Random, + Geography::JapanesePrefectures, Google::Adwords, Merge::HashRef, + PerlBuildSystem, Ubic, Pixie, Yahoo::Marketing, and XUL-Node The following modules are not based on Test::Builder, but may be of interest as alternatives to Test::Class. diff -Nru libtest-class-perl-0.47/t/bad-autoloads.t libtest-class-perl-0.50/t/bad-autoloads.t --- libtest-class-perl-0.47/t/bad-autoloads.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/bad-autoloads.t 2014-11-18 15:29:57.000000000 +0000 @@ -20,4 +20,4 @@ $SIG{ __WARN__ } = sub { $is_warning_free = 0 }; Test::Class->_isa_class( 'Contextual::Return::Value' ); ok $is_warning_free, 'avoided warnings from Contextual::Return::Value'; -} \ No newline at end of file +} diff -Nru libtest-class-perl-0.47/t/bailout.t libtest-class-perl-0.50/t/bailout.t --- libtest-class-perl-0.47/t/bailout.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/bailout.t 2014-11-18 15:29:57.000000000 +0000 @@ -15,4 +15,4 @@ test_test("bailout works"); is($?, 255, "exit value okay"); $?=0; -}; +} diff -Nru libtest-class-perl-0.47/t/compile.t libtest-class-perl-0.50/t/compile.t --- libtest-class-perl-0.47/t/compile.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/compile.t 2014-11-18 15:29:57.000000000 +0000 @@ -13,11 +13,11 @@ BEGIN { $stderr = IO::File->new_tmpfile or die "no tmp file ($!)\n"; *STDERR = $stderr; -}; +} my $sub = sub : Test(1) {print "ok\n"}; -sub foo : Test(foo) {print "ok\n"}; +sub foo : Test(foo) {print "ok\n"} END { @@ -26,4 +26,4 @@ "cannot test anon sub"); is(<$stderr>, "bad test definition 'foo' in main->foo\n", "bad number detected"); -}; +} diff -Nru libtest-class-perl-0.47/t/current_method.t libtest-class-perl-0.50/t/current_method.t --- libtest-class-perl-0.47/t/current_method.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/current_method.t 2014-11-18 15:29:57.000000000 +0000 @@ -10,17 +10,17 @@ sub test : Test { my $self = shift; is($self->current_method, "test", "current_method in method"); -}; +} sub setup : Test(setup => 1) { my $self = shift; is($self->current_method, "test", "current_method in setup"); -}; +} sub teardown : Test(teardown => 1) { my $self = shift; is($self->current_method, "test", "current_method in teardown"); -}; +} __PACKAGE__->runtests; diff -Nru libtest-class-perl-0.47/t/die_before_plan.t libtest-class-perl-0.50/t/die_before_plan.t --- libtest-class-perl-0.47/t/die_before_plan.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/die_before_plan.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,11 +11,11 @@ sub setup : Test(setup) { die "died before plan set\n"; -}; +} sub test : Test { ok(1==1, 'test just here to get setup method run'); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/expected_tests.t libtest-class-perl-0.50/t/expected_tests.t --- libtest-class-perl-0.47/t/expected_tests.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/expected_tests.t 2014-11-18 15:29:57.000000000 +0000 @@ -5,39 +5,39 @@ package Tests1; use base qw(Test::Class); -sub start : Test(setup => 1) {}; -sub test : Test(1) {}; -sub end : Test(teardown => 1) {}; +sub start : Test(setup => 1) {} +sub test : Test(1) {} +sub end : Test(teardown => 1) {} package Tests2; use base qw(Test::Class); -sub start : Test(setup => no_plan) {}; -sub test : Test(1) {}; -sub end : Test(teardown => 1) {}; +sub start : Test(setup => no_plan) {} +sub test : Test(1) {} +sub end : Test(teardown => 1) {} package Tests3; use base qw(Test::Class); -sub start : Test(setup => 1) {}; -sub test : Test(no_plan) {}; -sub end : Test(teardown => 1) {}; +sub start : Test(setup => 1) {} +sub test : Test(no_plan) {} +sub end : Test(teardown => 1) {} package Tests4; use base qw(Test::Class); -sub start : Test(setup => 1) {}; -sub test : Test(1) {}; -sub end : Test(teardown => no_plan) {}; +sub start : Test(setup => 1) {} +sub test : Test(1) {} +sub end : Test(teardown => no_plan) {} package Test5; use base qw(Test::Class); -sub startup :Test( startup => no_plan ) {}; -sub test : Test(1) {}; -sub shutdown :Test( shutdown => 1 ) {}; +sub startup :Test( startup => no_plan ) {} +sub test : Test(1) {} +sub shutdown :Test( shutdown => 1 ) {} package Test6; use base qw(Test::Class); -sub startup :Test( startup => 1 ) {}; -sub test : Test(1) {}; -sub shutdown :Test( shutdown => no_plan ) {}; +sub startup :Test( startup => 1 ) {} +sub test : Test(1) {} +sub shutdown :Test( shutdown => no_plan ) {} package main; use Test::More tests => 10; diff -Nru libtest-class-perl-0.47/t/fail1.t libtest-class-perl-0.50/t/fail1.t --- libtest-class-perl-0.47/t/fail1.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/fail1.t 2014-11-18 15:29:57.000000000 +0000 @@ -18,4 +18,4 @@ test_test("FAIL_ALL with plan"); is($?, 2, "exit value okay"); $?=0; -}; +} diff -Nru libtest-class-perl-0.47/t/fail2.t libtest-class-perl-0.50/t/fail2.t --- libtest-class-perl-0.47/t/fail2.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/fail2.t 2015-06-06 23:04:18.000000000 +0000 @@ -6,7 +6,7 @@ use Test::Builder::Tester; package Object; -sub new {return(undef)}; +sub new {return(undef)} package Object::Test; @@ -17,7 +17,7 @@ my $self = shift; isa_ok(Object->new, "Object") || $self->FAIL_ALL('cannot create Objects'); -}; +} package main; @@ -28,10 +28,9 @@ test_out(qr/not ok 1 - (?:The $identifier|undef) isa '?Object'?\n/); test_out("not ok 2 - cannot create Objects"); test_fail(-12); -test_err( $_ ) for $INC{'Test/Stream.pm'} - ? (qr/#\s+(?:The $identifier|undef) isn't defined\n/, "# (in Object::Test->_test_new)") - : ("# (in Object::Test->_test_new)", qr/#\s+(?:The $identifier|undef) isn't defined\n/); -test_fail(-16); +test_err( "# (in Object::Test->_test_new)" ); +test_err(qr/#\s+(?:The $identifier|undef) isn't defined\n/); +test_fail(-15); test_err( "# (in Object::Test->_test_new)" ); Object::Test->runtests; diff -Nru libtest-class-perl-0.47/t/fail3.t libtest-class-perl-0.50/t/fail3.t --- libtest-class-perl-0.47/t/fail3.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/fail3.t 2014-11-18 15:29:57.000000000 +0000 @@ -19,4 +19,4 @@ is($?, 1, "exit value okay"); print "1..2\n"; $?=0; -}; +} diff -Nru libtest-class-perl-0.47/t/filter_multiple.t libtest-class-perl-0.50/t/filter_multiple.t --- libtest-class-perl-0.47/t/filter_multiple.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/filter_multiple.t 2014-11-18 15:29:57.000000000 +0000 @@ -9,7 +9,7 @@ sub test_not_filtered : Test(1) { pass( "test_not_filtered doesn't meet any filters, so is run" ); -}; +} sub test_filter_me : Test(1) { fail( "shouldn't run, due to filtering of /filter_me/" ); diff -Nru libtest-class-perl-0.47/t/filter.t libtest-class-perl-0.50/t/filter.t --- libtest-class-perl-0.47/t/filter.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/filter.t 2014-11-18 15:29:57.000000000 +0000 @@ -9,7 +9,7 @@ sub test_run : Test(1) { pass( "test_run not filtered, so is run" ); -}; +} package Bar; use Test::More; diff -Nru libtest-class-perl-0.47/t/header.t libtest-class-perl-0.50/t/header.t --- libtest-class-perl-0.47/t/header.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/header.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,7 +11,7 @@ sub test : Test { pass("test in Test::Class"); -}; +} package main; use Test::More 'no_plan'; diff -Nru libtest-class-perl-0.47/t/late_header.t libtest-class-perl-0.50/t/late_header.t --- libtest-class-perl-0.47/t/late_header.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/late_header.t 2014-11-18 15:29:57.000000000 +0000 @@ -10,13 +10,13 @@ sub setup : Test(setup) { my $self = shift; $self->num_method_tests('test', 2); -}; +} sub test : Test(no_plan) { my $self = shift; is($self->num_tests, 2, 'test number set'); is($self->builder->expected_tests, 2, 'builder expected tests set'); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/methodinfo.t libtest-class-perl-0.50/t/methodinfo.t --- libtest-class-perl-0.47/t/methodinfo.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/methodinfo.t 2014-11-18 15:29:57.000000000 +0000 @@ -4,24 +4,24 @@ use warnings; use Test::More 'no_plan'; use constant CLASS => 'Test::Class::MethodInfo'; -BEGIN { use_ok( CLASS) }; +BEGIN { use_ok( CLASS) } { isa_ok my $o = CLASS->new(name=> 'foo'), CLASS; ok $o->is_type('test'), 'method type is test by default'; is $o->num_tests, 1, 'test methods default to 1 test'; -}; +} __END__ { isa_ok my $o = CLASS->new(name=> 'foo', num_tests => 0), CLASS; is $o->num_tests, 0, 'test method can have zero tests'; -}; +} { foreach my $type qw(setup teardown startup shutdown) { isa_ok my $o = CLASS->new(name=> 'foo', type=> $type), CLASS, $type; ok $o->is_type($type), "method type is $type"; is $o->num_tests, 0, "$type methods default to 0 test"; - }; -}; \ No newline at end of file + } +} diff -Nru libtest-class-perl-0.47/t/named_test.t libtest-class-perl-0.50/t/named_test.t --- libtest-class-perl-0.47/t/named_test.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/named_test.t 2014-11-18 15:29:57.000000000 +0000 @@ -10,7 +10,7 @@ sub default_name : Test( 1 ) { pass(); -}; +} package main; use Test::More 'no_plan'; diff -Nru libtest-class-perl-0.47/t/_new.t libtest-class-perl-0.50/t/_new.t --- libtest-class-perl-0.47/t/_new.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/_new.t 2014-11-18 15:29:57.000000000 +0000 @@ -7,7 +7,7 @@ BEGIN { use_ok('Test::Class') || Test::Builder->BAILOUT("CANNOT USE Test::Class"); -}; +} package Foo; use base qw(Test::Class); diff -Nru libtest-class-perl-0.47/t/num_method_tests.t libtest-class-perl-0.50/t/num_method_tests.t --- libtest-class-perl-0.47/t/num_method_tests.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/num_method_tests.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,7 +11,7 @@ my ($self, $n) = @_; my $m = $self->current_method; pass("$m just passing $_") foreach (1..$n); -}; +} sub new { my $class = shift; @@ -25,23 +25,23 @@ lives_ok {$self->num_method_tests('no_plan_test2', '+2')} 'updated extended'; is($self->num_method_tests('no_plan_test2'), '+2', 'update worked'); return($self); -}; +} -sub two_tests : Test(2) {$_[0]->passN(2)}; -sub no_plan_test : Test(no_plan) {$_[0]->passN(2)}; -sub no_plan_test2 : Test(no_plan) {$_[0]->passN(2)}; +sub two_tests : Test(2) {$_[0]->passN(2)} +sub no_plan_test : Test(no_plan) {$_[0]->passN(2)} +sub no_plan_test2 : Test(no_plan) {$_[0]->passN(2)} package Bar; use base qw(Foo); use Test::More; -sub no_plan_test : Test(+1) {pass("just passing"); $_[0]->SUPER::no_plan_test}; +sub no_plan_test : Test(+1) {pass("just passing"); $_[0]->SUPER::no_plan_test} sub new { my $class = shift; my $self = $class->SUPER::new(@_); is($self->num_method_tests('no_plan_test'), '+1', 'extended method okay'); return($self); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/num_tests.t libtest-class-perl-0.50/t/num_tests.t --- libtest-class-perl-0.47/t/num_tests.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/num_tests.t 2014-11-18 15:29:57.000000000 +0000 @@ -12,7 +12,7 @@ is($self->num_tests, 'no_plan', "num_tests access okay"); $self->num_tests(2); is($self->num_tests, 2, "num_tests set okay"); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/override.t libtest-class-perl-0.50/t/override.t --- libtest-class-perl-0.47/t/override.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/override.t 2015-06-06 22:36:43.000000000 +0000 @@ -13,7 +13,7 @@ { package Base::Test; use base qw( Test::Class ); - }; + } { package Broken::Test; diff -Nru libtest-class-perl-0.47/t/rt15870.t libtest-class-perl-0.50/t/rt15870.t --- libtest-class-perl-0.47/t/rt15870.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/rt15870.t 2014-11-18 15:29:57.000000000 +0000 @@ -5,7 +5,7 @@ use Test::Exception tests => 1; { package SomeClassThatDefinesNew; - sub new { return bless {}, shift }; + sub new { return bless {}, shift } } { package TestClassWithBrokenMI; @@ -13,4 +13,4 @@ } throws_ok { Test::Class->runtests } qr/Test::Class internals seem confused/, - 'sensible error if new() is overridden'; \ No newline at end of file + 'sensible error if new() is overridden'; diff -Nru libtest-class-perl-0.47/t/runtests_die.t libtest-class-perl-0.50/t/runtests_die.t --- libtest-class-perl-0.47/t/runtests_die.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_die.t 2015-06-06 23:04:18.000000000 +0000 @@ -4,7 +4,7 @@ use warnings; package Object; -sub new { undef }; +sub new { undef } package Foo; use Test::More; @@ -14,7 +14,7 @@ my $object = Object->new; isa_ok($object, "Object") or die("could not create object\n"); is($object->open, "open worked"); -}; +} package main; use Test::Builder::Tester tests => 1; @@ -25,11 +25,10 @@ test_out( qr/not ok 1 - (?:The $identifier|undef) isa '?Object'?\n/); test_err( "# Failed test ($filename at line 15)"); -test_err( $_ ) for $INC{'Test/Stream.pm'} - ? (qr/# (?:The $identifier|undef) isn't defined\n/, "# (in Foo->test_object)") - : ("# (in Foo->test_object)", qr/# (?:The $identifier|undef) isn't defined\n/); +test_err( "# (in Foo->test_object)" ); +test_err( qr/# (?:The $identifier|undef) isn't defined\n/); test_out( "not ok 2 - test_object died (could not create object)"); -test_err("# Failed test ($filename at line 34)"); -test_err("# (in Foo->test_object)"); +test_err( "# Failed test ($filename at line 33)"); +test_err( "# (in Foo->test_object)" ); Foo->runtests; test_test("early die handled"); diff -Nru libtest-class-perl-0.47/t/runtests_extra.t libtest-class-perl-0.50/t/runtests_extra.t --- libtest-class-perl-0.47/t/runtests_extra.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_extra.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,7 +11,7 @@ sub extra_test : Test(1) { ok(1, "expected test"); ok(1, "extra test"); -}; +} package main; use Test::Builder::Tester tests => 1; diff -Nru libtest-class-perl-0.47/t/runtests_noplan.t libtest-class-perl-0.50/t/runtests_noplan.t --- libtest-class-perl-0.47/t/runtests_noplan.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_noplan.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,15 +11,15 @@ sub set_tests : Test(1) { pass("this should pass"); -}; +} sub undef_tests : Test(no_plan) { my $self = shift; my $n = $self->{runtime_tests}; foreach $n (1..$n) { pass("runtime test $n"); - }; -}; + } +} package main; diff -Nru libtest-class-perl-0.47/t/runtests_of.t libtest-class-perl-0.50/t/runtests_of.t --- libtest-class-perl-0.47/t/runtests_of.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_of.t 2014-11-18 15:29:57.000000000 +0000 @@ -10,16 +10,16 @@ sub setup : Test(setup) { my $self = shift; $self->FAIL_ALL("premature plan") if $self->builder->expected_tests; -}; +} -sub test : Test { pass('Tests1 test') }; +sub test : Test { pass('Tests1 test') } package Tests2; use base qw(Test::Class); use Test::More; -sub test : Test { pass('Tests2 test') }; +sub test : Test { pass('Tests2 test') } package main; diff -Nru libtest-class-perl-0.47/t/runtests_result.t libtest-class-perl-0.50/t/runtests_result.t --- libtest-class-perl-0.47/t/runtests_result.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_result.t 2014-11-18 15:29:57.000000000 +0000 @@ -9,11 +9,11 @@ sub test1 : Test(1) { fail("fails"); -}; +} sub test2 : Test(1) { pass("passes"); -}; +} package Pass; @@ -22,7 +22,7 @@ sub test1 : Test(1) { pass("a successful test"); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/runtests_return.t libtest-class-perl-0.50/t/runtests_return.t --- libtest-class-perl-0.47/t/runtests_return.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_return.t 2014-11-18 15:29:57.000000000 +0000 @@ -12,7 +12,7 @@ return("darwin only test");# unless $^O eq "darwin"; ok(-w "/Library", "/Library writable"); ok(-r "/Library", "/Library readable"); -}; +} package Bar; use Test::More; @@ -24,7 +24,7 @@ return("darwin only test");# unless $^O eq "darwin"; ok(-r "/Library", "/Library readable"); ok(-w "/Library", "/Library writable"); -}; +} package main; diff -Nru libtest-class-perl-0.47/t/runtests.t libtest-class-perl-0.50/t/runtests.t --- libtest-class-perl-0.47/t/runtests.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,13 +11,13 @@ sub initialise1 :Test(setup) { my $self = shift; ++$self->{initialise1}; -}; +} sub initialise2 :Test(setup => 1) { my $self = shift; ++$self->{initialise2}; is($self->{initialise1}, $self->{initialise2}, "initialise2: methods ran in order"); -}; +} sub test1 :Test(4) { my $self = shift; @@ -26,19 +26,19 @@ is($self->{initialise2}, 1, 'test1: initialise2 ran once'); is($self->{test}, 1, 'test1: first test running'); is($self->{teardown1}, undef, 'test1: teardown not run'); -}; +} sub test2 : Test { fail("this failing tests should be overridden"); -}; +} sub teardown1 :Test(teardown => 1) { my $self = shift; my $m = $self->current_method; is($self->{test}, $self->{initialise1}, "teardown1: setup run for every test"); -}; +} package Bar; use base qw(Foo); @@ -52,7 +52,7 @@ is($self->{initialise2}, 2, 'test2: initialise2 ran twice'); is($self->{test}, 2, 'test2: second test running'); is($self->{teardown1}, 1, 'test2: teardown ran once'); -}; +} sub teardown1 :Test(teardown => +3) { my $self = shift; @@ -62,7 +62,7 @@ is($self->{initialise1}, $self->{teardown1}, "teardown1: teardown run for every initialise1"); is($self->{initialise2}, $self->{teardown1}, "teardown1: teardown run for every initialise2"); $self->SUPER::teardown1; -}; +} package main; use Test::More tests => 18; diff -Nru libtest-class-perl-0.47/t/runtests_trailing.t libtest-class-perl-0.50/t/runtests_trailing.t --- libtest-class-perl-0.47/t/runtests_trailing.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_trailing.t 2014-11-18 15:29:57.000000000 +0000 @@ -11,7 +11,7 @@ sub trailing_exception : Test(1) { pass("successful test"); die "died\n"; -}; +} package main; diff -Nru libtest-class-perl-0.47/t/runtests_with_wrong_class.t libtest-class-perl-0.50/t/runtests_with_wrong_class.t --- libtest-class-perl-0.47/t/runtests_with_wrong_class.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/runtests_with_wrong_class.t 2014-11-18 15:29:57.000000000 +0000 @@ -5,7 +5,7 @@ use Test::Exception; use Test::More tests => 2; -BEGIN { use_ok 'Test::Class' }; +BEGIN { use_ok 'Test::Class' } dies_ok { Test::Class->runtests( 'Not::A::Test::Class' ) } 'runtests dies if we are given something that is not a test class'; diff -Nru libtest-class-perl-0.47/t/skip1.t libtest-class-perl-0.50/t/skip1.t --- libtest-class-perl-0.47/t/skip1.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/skip1.t 2014-11-18 15:29:57.000000000 +0000 @@ -23,4 +23,4 @@ my $ok = $output[0] =~ /^1..0 # Skip skipping$/i; print "not " unless $ok; print "ok 1 - SKIP_ALL called skip_all\n"; -}; +} diff -Nru libtest-class-perl-0.47/t/skip2.t libtest-class-perl-0.50/t/skip2.t --- libtest-class-perl-0.47/t/skip2.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/skip2.t 2014-11-18 15:29:57.000000000 +0000 @@ -21,11 +21,11 @@ my $self = shift; $self->builder->ok(1==1); $self->SKIP_ALL("skippy"); -}; +} sub test : Test(3) { die "this should never run!"; -}; +} test_out("ok 1 - test"); test_out("ok 2 # skip skippy"); diff -Nru libtest-class-perl-0.47/t/skip_class_reason.t libtest-class-perl-0.50/t/skip_class_reason.t --- libtest-class-perl-0.47/t/skip_class_reason.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/skip_class_reason.t 2014-11-18 15:29:57.000000000 +0000 @@ -13,7 +13,7 @@ use base qw(Test::Class); use Test::More; - sub skipped_with_reason : Test( 3 ) { fail( "this should not run" ) }; + sub skipped_with_reason : Test( 3 ) { fail( "this should not run" ) } __PACKAGE__->SKIP_CLASS( 'because SKIP_CLASS returned a string' ); } @@ -22,7 +22,7 @@ use base qw(Test::Class); use Test::More; - sub skipped_with_reason : Test( 3 ) { fail( "this should not run" ) }; + sub skipped_with_reason : Test( 3 ) { fail( "this should not run" ) } __PACKAGE__->SKIP_CLASS( 1 ); } @@ -45,11 +45,11 @@ $actual =~ s{# skip\b}{# skip}i; # normalize directives my $expected=; chomp($expected); ok($actual, $expected); - }; + } ok($?, 0, "exit value okay"); $?=0; -}; +} __DATA__ 1..1 diff -Nru libtest-class-perl-0.47/t/skip_empty_classes.t libtest-class-perl-0.50/t/skip_empty_classes.t --- libtest-class-perl-0.47/t/skip_empty_classes.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/skip_empty_classes.t 2014-11-18 15:29:57.000000000 +0000 @@ -58,11 +58,11 @@ # chomp($actual); # my $expected=; chomp($expected); # ok($actual, $expected); -# }; +# } # # ok($?, 0, "exit value okay"); # $?=0; -# }; +# } # # __DATA__ # 1..1 diff -Nru libtest-class-perl-0.47/t/spaces.t libtest-class-perl-0.50/t/spaces.t --- libtest-class-perl-0.47/t/spaces.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/spaces.t 2014-11-18 15:29:57.000000000 +0000 @@ -10,7 +10,7 @@ sub test : Test( 1 ) { pass("it works"); -}; +} package main; use Test::More 'no_plan'; diff -Nru libtest-class-perl-0.47/t/startup.t libtest-class-perl-0.50/t/startup.t --- libtest-class-perl-0.47/t/startup.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/startup.t 2014-11-18 15:29:57.000000000 +0000 @@ -30,22 +30,22 @@ $caller =~ s/^.*://s; my $expected = shift @ORDER; is($caller, $expected, "called $expected"); -}; +} -sub start1 : Test(startup=>1) { trace_ok() }; -sub start2 : Test(startup=>1) { trace_ok() }; +sub start1 : Test(startup=>1) { trace_ok() } +sub start2 : Test(startup=>1) { trace_ok() } -sub setup1 : Test(setup=>1) { trace_ok() }; -sub setup2 : Test(setup=>1) { trace_ok() }; +sub setup1 : Test(setup=>1) { trace_ok() } +sub setup2 : Test(setup=>1) { trace_ok() } -sub test1 : Test(1) { trace_ok() }; -sub test2 : Test(1) { trace_ok() }; +sub test1 : Test(1) { trace_ok() } +sub test2 : Test(1) { trace_ok() } -sub tear1 : Test(teardown=>1) { trace_ok() }; -sub tear2 : Test(teardown=>1) { trace_ok() }; +sub tear1 : Test(teardown=>1) { trace_ok() } +sub tear2 : Test(teardown=>1) { trace_ok() } -sub end1 : Test(shutdown=>1) { trace_ok() }; -sub end2 : Test(shutdown=>1) { trace_ok() }; +sub end1 : Test(shutdown=>1) { trace_ok() } +sub end2 : Test(shutdown=>1) { trace_ok() } package main; diff -Nru libtest-class-perl-0.47/t/test_deep.t libtest-class-perl-0.50/t/test_deep.t --- libtest-class-perl-0.47/t/test_deep.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/test_deep.t 2014-11-18 15:29:57.000000000 +0000 @@ -6,8 +6,8 @@ use Test::Class; { package Test::Deep; - sub isa { 1 }; + sub isa { 1 } } is_deeply [ Test::Class->_test_classes ], [ 'Test::Class' ], - 'Test::Deep is not included as a test class, even though isa always returns true'; \ No newline at end of file + 'Test::Deep is not included as a test class, even though isa always returns true'; diff -Nru libtest-class-perl-0.47/t/Tests.t libtest-class-perl-0.50/t/Tests.t --- libtest-class-perl-0.47/t/Tests.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/Tests.t 2014-11-18 15:29:57.000000000 +0000 @@ -12,14 +12,14 @@ sub Tests_attribute_default_number_of_tests :Tests { my $self = shift; is( $self->num_tests, 'no_plan' ); - }; + } sub Tests_attribute_set_number_of_tests :Tests(1) { my $self = shift; is( $self->num_tests, 1 ); - }; + } -}; +} My::Test->runtests; diff -Nru libtest-class-perl-0.47/t/test_verbose.t libtest-class-perl-0.50/t/test_verbose.t --- libtest-class-perl-0.47/t/test_verbose.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/test_verbose.t 2014-11-18 15:29:57.000000000 +0000 @@ -7,8 +7,8 @@ use base qw(Test::Class); use Test::More; -sub test1 : Test { ok(1) }; -sub test2 : Test { ok(1) }; +sub test1 : Test { ok(1) } +sub test2 : Test { ok(1) } package main; use Test::Builder::Tester tests => 1; diff -Nru libtest-class-perl-0.47/t/todo.t libtest-class-perl-0.50/t/todo.t --- libtest-class-perl-0.47/t/todo.t 2014-09-27 04:05:24.000000000 +0000 +++ libtest-class-perl-0.50/t/todo.t 2014-11-18 15:29:57.000000000 +0000 @@ -4,7 +4,7 @@ use warnings; package Object; -sub live {undef}; +sub live {undef} package Foo; @@ -14,7 +14,7 @@ sub todo_test : Test { local $TODO = "unimplemented"; ok(Object->live, "object live"); -}; +} package main; use Test::Builder::Tester tests => 2;