Test-Class-Most-0.07000755001750001750 012022070300 13363 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/README000444001750001750 154312022070300 14403 0ustar00cpoecpoe000000000000Test-Class-Most Make Test::Class even easier to use. INSTALLATION To install this module, run the following commands: perl Build.PL ./Build ./Build test ./Build install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Test::Class::Most You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Class-Most AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/Test-Class-Most CPAN Ratings http://cpanratings.perl.org/d/Test-Class-Most Search CPAN http://search.cpan.org/dist/Test-Class-Most/ COPYRIGHT AND LICENCE Copyright (C) 2010 Curtis "Ovid" Poe This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Test-Class-Most-0.07/Makefile.PL000444001750001750 60712022070300 15455 0ustar00cpoecpoe000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.40 use ExtUtils::MakeMaker; WriteMakefile ( 'NAME' => 'Test::Class::Most', 'VERSION_FROM' => 'lib/Test/Class/Most.pm', 'PREREQ_PM' => { 'Test::Class' => '0.33', 'Test::Most' => '0.31' }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {} ) ; Test-Class-Most-0.07/MANIFEST000444001750001750 44712022070300 14636 0ustar00cpoecpoe000000000000Build.PL Changes lib/Test/Class/Most.pm Makefile.PL MANIFEST META.yml README t/test_class_load.t t/lib/My/Test/Class.pm t/lib/My/Test/Class/Child.pm t/lib/My/Test/Class/Child/Grandchild.pm t/lib/My/Test/Class/Child/ISuckAtOO.pm t/lib/My/Test/Class/Child2.pm xt/pod-coverage.t xt/pod.t META.json Test-Class-Most-0.07/Build.PL000444001750001750 115612022070300 15017 0ustar00cpoecpoe000000000000use strict; use warnings; use Module::Build; my $builder = Module::Build->new( module_name => 'Test::Class::Most', license => 'perl', dist_author => 'Curtis "Ovid" Poe ', dist_version_from => 'lib/Test/Class/Most.pm', requires => { 'Test::Most' => 0.31, 'Test::Class' => 0.33, }, meta_merge => { resources => { repository => 'http://github.com/Ovid/Test-Class-Most/', }, }, add_to_cleanup => ['Test-Class-Most-*'], create_makefile_pl => 'traditional', ); $builder->create_build_script(); Test-Class-Most-0.07/Changes000444001750001750 225412022070300 15016 0ustar00cpoecpoe000000000000Revision history for Test-Class-Most 0.07 September 6, 2012 - No functional change. Bump Test::Most dependency to 0.31. This fixes prototype warnings when using Moose. 0.06 December 29, 2011 - Added is_abstract property. 0.05 April 10, 2010 - Extended and reorganized the documentation. - Add 'attributes' to Test::Class::Most. http://blogs.perl.org/users/ovid/2010/04/vienna-perl-qa-hackathon-day-1.html 0.04 February 6, 2010 - Removed all trace of "feature" and "mro" handling. This is because it turns out to be fraught with error (what happens if your inheritance heirarchy tries to use different MROs in different classes? You should not be using multiple inheritance anyway! 0.03 February 4, 2010 - Remove bad shebang causing some tests to fail if /usr/bin/env picks up a perl not in their path. 0.02 February 3, 2010 - Fix a broken diagnostic message in t/lib/My/Test/Class.pm - Correct the MANIFEST for a renamed file. - Add repository info to Build.PL 0.01 Date/time First version, released on an unsuspecting world. Test-Class-Most-0.07/META.json000444001750001750 202112022070300 15134 0ustar00cpoecpoe000000000000{ "abstract" : "Test Classes the easy way", "author" : [ "Curtis \"Ovid\" Poe " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4, CPAN::Meta::Converter version 2.120351", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Test-Class-Most", "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0.4" } }, "runtime" : { "requires" : { "Test::Class" : "0.33", "Test::Most" : "0.31" } } }, "provides" : { "Test::Class::Most" : { "file" : "lib/Test/Class/Most.pm", "version" : "0.07" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "url" : "http://github.com/Ovid/Test-Class-Most/" } }, "version" : "0.07" } Test-Class-Most-0.07/META.yml000444001750001750 116412022070300 14773 0ustar00cpoecpoe000000000000--- abstract: 'Test Classes the easy way' author: - "Curtis \"Ovid\" Poe " build_requires: {} configure_requires: Module::Build: 0.4 dynamic_config: 1 generated_by: 'Module::Build version 0.4, CPAN::Meta::Converter version 2.120351' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Test-Class-Most provides: Test::Class::Most: file: lib/Test/Class/Most.pm version: 0.07 requires: Test::Class: 0.33 Test::Most: 0.31 resources: license: http://dev.perl.org/licenses/ repository: http://github.com/Ovid/Test-Class-Most/ version: 0.07 Test-Class-Most-0.07/t000755001750001750 012022070300 13626 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/test_class_load.t000444001750001750 54712022070300 17301 0ustar00cpoecpoe000000000000BEGIN { $SIG{__WARN__} = sub { my $warning = shift; return if $warning =~ /String found|predeclare/; CORE::warn($warning); }; } use lib 't/lib'; use Test::More; use Test::Class::Load 't/lib'; diag("Testing Test::Class::Most $Test::Class::Most::VERSION, Perl $], $^X"); diag("Testing Test::Class $Test::Class::VERSION"); Test-Class-Most-0.07/t/lib000755001750001750 012022070300 14374 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/lib/My000755001750001750 012022070300 14761 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/lib/My/Test000755001750001750 012022070300 15700 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/lib/My/Test/Class.pm000444001750001750 205612022070300 17443 0ustar00cpoecpoe000000000000package My::Test::Class; use Test::Class::Most is_abstract => 1; INIT { Test::Class->runtests } sub parent { ['Test::Class'] } sub startup : Tests(startup) {} sub setup : Tests(setup) {} sub teardown : Tests(teardown) {} sub shutdown : Tests(shutdown) {} sub sanity : Tests(2) { my $test = shift; { no strict 'refs'; my $class = ref $test; eq_or_diff \@{"${class}::ISA"}, $test->parent, 'Inheritance should be handled correctly'; } eval '$foo = 1'; my $error = $@; like $error, qr/^Global symbol "\$foo" requires explicit package name/, '... and we should automatically have strict turned on'; } sub is_abstract { my $test = shift; return Test::Class::Most->is_abstract($test); } sub verify_abstract_behavior : Tests(1) { my $test = shift; my $test_class = ref $test; my $is_abstract = Test::Class::Most->is_abstract($test_class); my $maybe = $is_abstract ? "" : "not"; is $test->is_abstract, $is_abstract, "$test_class should $maybe be abstract"; } 1; Test-Class-Most-0.07/t/lib/My/Test/Class000755001750001750 012022070300 16745 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/lib/My/Test/Class/Child.pm000444001750001750 45412022070300 20446 0ustar00cpoecpoe000000000000package My::Test::Class::Child; use Test::Class::Most parent => 'My::Test::Class', is_abstract => 1, attributes => 'child1'; sub startup : Tests(startup) { my $test = shift; $test->SUPER::startup; $test->child1('from child1'); } sub parent { ['My::Test::Class']; } 1; Test-Class-Most-0.07/t/lib/My/Test/Class/Child2.pm000444001750001750 14112022070300 20521 0ustar00cpoecpoe000000000000package My::Test::Class::Child2; # no need for any inheritance sub child2 { 'from child2' } 1; Test-Class-Most-0.07/t/lib/My/Test/Class/Child000755001750001750 012022070300 17770 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/t/lib/My/Test/Class/Child/Grandchild.pm000444001750001750 45612022070300 22507 0ustar00cpoecpoe000000000000package My::Test::Class::Child::Grandchild; use Test::Class::Most parent => 'My::Test::Class::Child'; sub parent { ['My::Test::Class::Child'] } sub test_functions : Tests(2) { ok 1, 'We should still have test functions available'; eval '$foo = 1'; ok $@, '... and strict enabled'; } 1; Test-Class-Most-0.07/t/lib/My/Test/Class/Child/ISuckAtOO.pm000444001750001750 76512022070300 22214 0ustar00cpoecpoe000000000000package My::Test::Class::Child::ISuckAtOO; use Test::Class::Most parent => [qw/ My::Test::Class::Child My::Test::Class::Child2 /]; sub parent { [qw/My::Test::Class::Child My::Test::Class::Child2/] } sub multiple_inheritance_sucks : Tests { my $test = shift; can_ok $test, 'child1'; is $test->child1, 'from child1', '... and it should return the correct value'; can_ok $test, 'child2'; is $test->child2, 'from child2', '... and it should return the correct value'; } 1; Test-Class-Most-0.07/lib000755001750001750 012022070300 14131 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/lib/Test000755001750001750 012022070300 15050 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/lib/Test/Class000755001750001750 012022070300 16115 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/lib/Test/Class/Most.pm000444001750001750 2102012022070300 17545 0ustar00cpoecpoe000000000000package Test::Class::Most; use warnings; use strict; use Test::Class; use Carp 'croak'; =head1 NAME Test::Class::Most - Test Classes the easy way =head1 VERSION Version 0.07 =cut our $VERSION = '0.07'; $VERSION = eval $VERSION; =head1 SYNOPSIS Instead of this: use strict; use warnings; use Test::Exception 0.88; use Test::Differences 0.500; use Test::Deep 0.106; use Test::Warn 0.11; use Test::More 0.88; use parent 'My::Test::Class'; sub some_test : Tests { ... } You type this: use Test::Class::Most parent => 'My::Test::Class'; sub some_test : Tests { ... } =head1 DESCRIPTION When people write test classes with the excellent C, you often see the following at the top of the code: package Some::Test::Class; use strict; use warnings; use base 'My::Test::Class'; use Test::More; use Test::Exception; # and then the tests ... That's a lot of boilerplate and I don't like boilerplate. So now you can do this: use Test::Class::Most parent => 'My::Test::Class'; That automatically imports L and L for you. It also gives you all of the testing goodness from L. =head1 CREATING YOUR OWN BASE CLASS You probably want to create your own base class for testing. To do this, simply specify no import list: package My::Test::Class; use Test::Class::Most; # we now inherit from Test::Class INIT { Test::Class->runtests } 1; And then your other classes inherit as normal (well, the way we do it): package Tests::For::Foo; use Test::Class::Most parent => 'My::Test::Class'; And you can inherit from those other classes, too: package Tests::For::Foo::Child; use Test::Class::Most parent => 'Tests::For::Foo'; Of course, it's quite possible that you're a fan of multiple inheritance, so you can do that, too (I was I tempted to not allow this, but I figured I shouldn't force too many of my personal beliefs on you): package Tests::For::ISuckAtOO; use Test::Class::Most parent => [qw/ Tests::For::Foo Tests::For::Bar Some::Other::Class::For::Increased::Stupidity /]; As a side note, it's recommended that even if you don't need test control methods in your base class, put stubs in there: package My::Test::Class; use Test::Class::Most; # we now inherit from Test::Class INIT { Test::Class->runtests } sub startup : Tests(startup) {} sub setup : Tests(setup) {} sub teardown : Tests(teardown) {} sub shutdown : Tests(shutdown) {} 1; This allows developers to I be able to safely call parent test control methods rather than wonder if they are there: package Tests::For::Customer; use Test::Class::Most parent => 'My::Test::Class'; sub setup : Tests(setup) { my $test = shift; $test->next::method; # safe due to stub in base class ... } =head1 ATTRIBUTES You can also specify "attributes" which are merely very simple getter/setters. use Test::Class::Most parent => 'My::Test::Class', attributes => [qw/customer items/], is_abstract => 1; sub setup : Tests(setup) { my $test = shift; $test->SUPER::setup; $test->customer( ... ); $test->items( ... ); } sub some_tests : Tests { my $test = shift; my $customer = $test->customer; ... } If called with no arguments, returns the current value. If called with one argument, sets that argument as the current value. If called with more than one argument, it croaks. =head1 ABSTRACT CLASSES You may pass an optional C parameter in the import list. It takes a boolean value. This value is advisory only and is not inherited. It defaults to false if not provided. Sometimes you want to identify a test class as "abstract". It may have a bunch of tests, but those should only run for its subclasses. You can pass C< 1>> in the import list. Then, to test if a given class or instance of that class is "abstract": sub dont_run_in_abstract_base_class : Tests { my $test = shift; return if Test::Class::Most->is_abstract($test); ... } Note that C is strictly B. You are expected (required) to check the value yourself and take appropriate action. We recommend adding the following method to your base class: sub is_abstract { my $test = shift; return Test::Class::Most->is_abstract($test); } And later in a subclass: if ( $test->is_abstract ) { ... } =head1 EXPORT All functions from L are automatically exported into your namespace. =cut { my %IS_ABSTRACT; sub is_abstract { my ( undef, $proto ) = @_; my $test_class = ref $proto || $proto; return $IS_ABSTRACT{$test_class}; } sub import { my ( $class, %args ) = @_; my $caller = caller; eval "package $caller; use Test::Most;"; croak($@) if $@; warnings->import; strict->import; if ( my $parent = delete $args{parent} ) { if ( ref $parent && 'ARRAY' ne ref $parent ) { croak( "Argument to 'parent' must be a classname or array of classnames, not ($parent)" ); } $parent = [$parent] unless ref $parent; foreach my $p (@$parent) { eval "use $p"; croak($@) if $@; } no strict 'refs'; push @{"${caller}::ISA"} => @$parent; } else { no strict 'refs'; push @{"${caller}::ISA"} => 'Test::Class'; } if ( my $attributes = delete $args{attributes} ) { if ( ref $attributes && 'ARRAY' ne ref $attributes ) { croak( "Argument to 'attributes' must be a classname or array of classnames, not ($attributes)" ); } $attributes = [$attributes] unless ref $attributes; foreach my $attr (@$attributes) { my $method = "$caller\::$attr"; no strict 'refs'; *$method = sub { my $test = shift; return $test->{$method} unless @_; if ( @_ > 1 ) { croak("You may not pass more than one argument to '$method'"); } $test->{$method} = shift; return $test; }; } } if ( my $is_abstract = delete $args{is_abstract} ) { $IS_ABSTRACT{$caller} = $is_abstract; } else { $IS_ABSTRACT{$caller} = 0; } } } =head1 TUTORIAL If you're not familiar with using L, please see my tutorial at: =over 4 =item * L =item * L =item * L =item * L =item * L =back =head1 AUTHOR Curtis "Ovid" Poe, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Test::Class::Most You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 SEE ALSO =over 4 =item * L xUnit-style testing in Perl =item * L The most popular CPAN test modules bundled into one module. =item * L I stole this code. Thanks C! =back =head1 ACKNOWLEDGEMENTS Thanks to Adrian Howard for L, Adam Kennedy for maintaining it and C for L. =head1 COPYRIGHT & LICENSE Copyright 2010 Curtis "Ovid" Poe, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut no warnings 'void'; "Boilerplate is bad, m'kay"; Test-Class-Most-0.07/xt000755001750001750 012022070300 14016 5ustar00cpoecpoe000000000000Test-Class-Most-0.07/xt/pod-coverage.t000444001750001750 104712022070300 16715 0ustar00cpoecpoe000000000000use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); Test-Class-Most-0.07/xt/pod.t000444001750001750 35012022070300 15100 0ustar00cpoecpoe000000000000#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok();