Test::CompanionClasses::Base - Base class for test companion classes
version 1.101370
package My::Foo_TEST; use warnings; use strict; use base 'Test::CompanionClasses::Base'; use constant PLAN => 5; sub run { my $self = shift; $self->SUPER::run(@_); is_deeply($foo, $bar, 'some test'); # ... }
Base class for test companion classes. Each test companion class should inherit from this class.
The package() property is automatically set; it holds the package name of the class you are testing. If your test companion class is called My::Foo_TEST, then package() will return My::Foo.
My::Foo_TEST
package()
My::Foo
A constant that says how many tests this particular class defines. Real test companion classes (i.e., subclasses of this class) will want to redefine it like this:
use constant PLAN => 5;
Note that you should only specify how many tests the current class runs; test counts of superclasses are automatically taken care of.
Uses PLAN(), calculated over the test companion class' whole class hierarchy, to determine how many tests will be run in total.
PLAN()
Loads the actual class being tested (see package()) and returns an object of this class (constructed by calling new() on it).
new()
In your test companion class you will want to test certain assumptions about your real class, so this method will be useful.
Test companion classes should override this method and run their tests. Be sure to call SUPER::run(@_) so that all tests over the class hierarchy are run.
SUPER::run(@_)
The run() method in this base class just prints a line informing the test user that tests for this particular companion class have begun. If you have several companion classes - and you probably will or you won't have been using Test::CompanionClasses - this serves as a visual distinction of where on companion class' tests end the next ones' begin.
run()
Test::CompanionClasses
See perlmodinstall for information and options on installing Perl modules.
No bugs have been reported.
Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Test-CompanionClasses.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/Test-CompanionClasses/.
The development version lives at http://github.com/hanekomu/Test-CompanionClasses/. Instead of sending patches, please fork this project using the standard git and github infrastructure.
Marcel Gruenauer <marcel@cpan.org>
This software is copyright (c) 2007 by Marcel Gruenauer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::CompanionClasses, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::CompanionClasses
CPAN shell
perl -MCPAN -e shell install Test::CompanionClasses
For more information on module installation, please visit the detailed CPAN module installation guide.