|
NAMEFennec::Lite - Minimalist Fennec, the commonly used bits.DESCRIPTIONFennec does a ton, but it may be hard to adopt it all at once. It also is a large project, and has not yet been fully split into component projects. Fennec::Lite takes a minimalist approach to do for Fennec what Mouse does for Moose.Fennec::Lite is a single module file with no non-core dependencies. It can easily be used by any project, either directly, or by copying it into your project. The file itself is less than 300 lines of code at the time of this writing, that includes whitespace. This module does not cover any of the more advanced features such as result capturing or SPEC workflows. This module only covers test grouping and group randomization. You can also use the FENNEC_ITEM variable with a group name or line number to run a specific test group only. Test::Builder is used under the hood for TAP output. SYNOPSISSIMPLE#!/usr/bin/perl use strict; use warnings; # Brings in Test::More for us. use Fennec::Lite; tests good => sub { ok( 1, "A good test" ); }; # You most call run_tests() after declaring your tests. run_tests(); done_testing(); ADVANCED#!/usr/bin/perl use strict; use warnings; use Fennec::Lite plan => 8, random => 1, testing => 'My::Class', alias => [ 'My::Class::ThingA' ], alias_to => { TB => 'My::Class::ThingB', }; # Quickly create get/set accessors fennec_accessors qw/ construction_string /; # Create a constructor for our test class. sub new { my $class = shift; my $string = @_; return bless({ construction_string => $string }, $class ); } tests good => sub { # Get $self. Created with new() my $self = shift; $self->isa_ok( __PACKAGE__ ); is( $self->construction_string, "This is the construction string", "Constructed properly" ); ok( 1, "A good test" ); }; tests "todo group" => ( todo => "This will fail", code => sub { ok( 0, "false value" )}, ); tests "skip group" => ( skip => "This will fail badly", sub => sub { die "oops" }, ); run_tests( "This is the construction string" ); Pure OO Interface#!/usr/bin/perl use strict; use warnings; use Fennec::Lite (); use Test::More; my $fennec = Fennec::Lite->new( test_class => __PACKAGE__ ); $fennec->add_tests( "test name" => sub { ok( ... ); }); $fennec->run_tests; done_testing(); IMPORTED FOR YOUWhen you use Fennec::Lite, Test::More is automatically imported for you. In addition Test::Warn and Test::Exception will also be loaded, but only if they are installed.IMPORT ARGUMENTSuse Fennec::Lite %ARGS
RUNNING IN RANDOM ORDERBy default test groups will be run in a random order. The random seed is the current date (YYYYMMDD). This is used so that the order does not change on the day you are editing your code. However the ardor will change daily allowing for automated testing to find order dependent failures.You can manually set the random seed to reproduce a failure. The FENNEC_SEED environment variable will be used as the seed when it is present. $ FENNEC_SEED="20100915" prove -I lib -v t/*.t RUNNING SPECIFIC GROUPSYou can use the FENNEC_ITEM variable with a group name or line number to run a specific test group only.$ FENNEC_ITEM="22" prove -I lib -v t/MyTest.t $ FENNEC_ITEM="Test Group A" prove -I lib -v t/MyTest.t This can easily be integrated into an editor such as vim or emacs. EXPORTED FUNCTIONS
PURE OO INTERFACE METHODS
Extending Fennec::LiteIn the tradition of the Fennec project, Fennec::Lite is designed to be extensible. You can even easily subclass/edit Fennec::Lite to work with alternatives to Test::Builder.METHODS TO OVERRIDE
FENNEC PROJECTThis module is part of the Fennec project. See Fennec for more details. Fennec is a project to develop an extensible and powerful testing framework. Together the tools that make up the Fennec framework provide a potent testing environment.The tools provided by Fennec are also useful on their own. Sometimes a tool created for Fennec is useful outside the greater framework. Such tools are turned into their own projects. This is one such project.
AUTHORSChad Granum exodist7@gmail.comCOPYRIGHTCopyright (C) 2010 Chad GranumFennec-Lite is free software; Standard perl license. Fennec-Lite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
Visit the GSP FreeBSD Man Page Interface. |