Test::FITesque(3pm) | User Contributed Perl Documentation | Test::FITesque(3pm) |
Test::FITesque - the FITesque framework!
Version 0.04
Test::FITesque is a framework designed to emulate the FIT <http://fit.c2.com> framework, but with a more perlish touch. While it is possible to use the FIT framework from within perl, it has a lot of unnecessary overhead related to its origins in the Java world.
I created Test::FITesque for the following reasons:
FITesque starts with creating FITesque fixtures which are simply packages which allow for the creation of objects upon which methods can be called.
package MyApp::Test::Fixture; use strict; use warnings; use base qw(Test::FITesque::Fixture); use Test::More; file_exists : Test { my ($self, $file) = @_; ok -e $file, qq{File '$file' exists}; }
This simple fixture can now be run with a very basic and simple test.
my $test = Test::FITesque::Test->new({ data => [ ['MyApp::Test::Fixture'], ['file_exists', '/etc/hosts'] ] }); $test->run_tests();
The data option is simply a table of data to use when executing the fixture test. The first row must refer to the name of the Test::FITesque::Fixture based fixture you wish to execute (like MyApp::Test::Fixture above). Any other cells in this row will be passed to the new() method on the Fixture class.
The following rows are all method calls on an instance of the Fixture class. This first cell must refer to a method name in the Fixture class, all following cells will be passed to the methods as arguments.
The run_tests() method on the FITesque test will simply run these methods in the order specified while taking care of maintaining TAP test count and the like underneath.
If you have more than one instance of a test to run, you can add it to a suite.
my $suite = Test::FITesque::Suite->new({ data => [$test1, $test2, $test3] }); $suite->run_tests();
This will also allow you to run test fixtures in a more dynamic fashion while still taking care of TAP test count.
Suites can not only take a list of tests to run, but also suites themselves.
The Test::FITesque package also supplies some handy helper functions to wrap most of the logic up for you. Please see the SYNOPSIS below for more information.
use Test::FITesque; run_tests { suite { ... }, test { ['MyApp::Test::Fixture'], ['file_exists', '/etc/hosts'] } };
test { ['Fixture::Class'], ['divides', qw(8 4 2)], ['multiplies', qw(5 6 30)], ['adds', qw(4 3 7)], }
This function will return a Test::FITesque::Test object. It takes a coderef which returns a list of array references of which the first must refer to your FITesque fixture.
suite { test { ... }, test { ... }, suite { test { ... } }, }
This function will return a Test::FITesque::Suite object. It takes a coderef which returns a list of Test::FITesque::Test objects or/and Test::FITesque::Suite objects.
run_tests { suite { ... }, test { ... } }
This function takes a coderef of suite and/or test objects. This will then wrap these all into a suite and call Test::FITesque::Suite's run_tests method.
Test::FITesque::Fixture, Test::FITesque::Test, Test::FITesque::Suite
This distribution is heavily unit and system tested for compatibility with Test::Builder. If you come across any bugs, please send me or submit failing tests to Test-FITesques RT queue. Please see the 'SUPPORT' section below on how to supply these.
---------------------------- ------ ------ ------ ------ ------ ------ ------ File stmt bran cond sub pod time total ---------------------------- ------ ------ ------ ------ ------ ------ ------ blib/lib/Test/FITesque.pm 100.0 100.0 n/a 100.0 100.0 5.2 100.0 .../Test/FITesque/Fixture.pm 100.0 100.0 100.0 100.0 100.0 29.1 100.0 ...ib/Test/FITesque/Suite.pm 100.0 100.0 100.0 100.0 100.0 14.6 100.0 ...lib/Test/FITesque/Test.pm 100.0 100.0 100.0 100.0 100.0 51.1 100.0 Total 100.0 100.0 100.0 100.0 100.0 100.0 100.0 ---------------------------- ------ ------ ------ ------ ------ ------ ------
Scott McWhirter, "<konobi at cpan.org>"
Please report any bugs or feature requests to "bug-test-fitesque at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-FITesque>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Due to limitations in the TAP protocol and perl's TAP tools such as Test::Harness, all Fixture tables have to be held in memory. It also means that Fixture tables cannot be treated as a stream so there is no easy way to separate out which tables output is which. To remedy this, I suggest that you pass a 'name' parameter to the Fixture classes constructor and print this to screen or use the diag() function from Test::More.
You can find documentation for this module with the perldoc command.
perldoc Test::FITesque
You can also look for information at:
<http://annocpan.org/dist/Test-FITesque>
<http://cpanratings.perl.org/d/Test-FITesque>
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-FITesque>
<http://search.cpan.org/dist/Test-FITesque>
Copyright 2007 Scott McWhirter, all rights reserved.
This program is released under the following license: BSD. Please see the LICENSE file included in this distribution for details.
2022-07-04 | perl v5.34.0 |