Andrew F. Hampe > Wetware-Test > Wetware::Test::Class

Download:
Wetware-Test-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Wetware::Test::Class - Test::Class base class

SYNOPSIS ^

  package Wetware::My::TestSuite;
  use base Wetware::Test::Class;
  # write tests as normal...

DESCRIPTION ^

This base class provides the magic that allows you to run individual Test::Class-based modules like regular test scripts. For example, either of these will work as long as the TestSuite.pm inherits from this module:

 prove t/lib/Wetware/My/TestSuite.pm

 ./Build test --test_files=t/lib/Wetware/My/TestSuite.pm

Note that you do not need to inherit from Test::Class if you use this module as your base. For reference see:

http://search.cpan.org/~adie/Test-Class-0.31/lib/Test/Class/Load.pm#CUSTOMIZING_TEST_RUNS

METHODS

This implements an is_test_class() that overrides the base method.

This returns true IF the file is 'TestSuite.pm'.

This will allow us to point at the blib/lib without having to worry about considering all of the *.pm files as TestSuites.

BUG

A conflict will arise IF one is using the Test::Compile approach to testing all of the perl modules in blib, AND one of them is a Test Class based module. The error will look something like:

 t/00_compile_pm.t ............. 1/2 Too late to run INIT block at 
 /usr/local/lib/perl5/site_perl/5.8.7/Wetware/Test/Class.pm line 22.

where the script t/00_compile_pm.t is of the form:

 use strict;
 use warnings;
 use Test::Compile;

 all_pm_files_ok();

I have not yet solved a way to avoid this conflict.

The best advice is to limit what is in a given distribution IF it will be installing a Test Class Module that is expected to be inherited for test purposes for those subclassing both the Class and it's Test Classes.

In that case use the stock 00-load.t approach:

 use Test::More tests => 1;

 BEGIN {
   use_ok( 'Wetware::CLI' );
 }

If one does not need to have the Test Class Module in blib, then putting them in t/lib and running the simple 01_test_class.t script

 use strict;
 use warnings;
 use FindBin qw($Bin);
 use Test::Class::Load "$Bin/lib";

will not cause the conflict.

SEE ALSO ^

Test::Class

Test::Class::Load

Wetware::Test::Utilities

AUTHOR ^

"drieux", <"drieux [AT] at wetware.com">

COPYRIGHT & LICENSE ^

Copyright 2009 "drieux", all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: