NAME
Fennec::Manual::Quickstart - Dive right into using Fennec.
DESCRIPTION
This is the quickstart guide to using Fennec. For additional documentation see Fennec::Manual.
SIMPLE EXAMPLE
#!/usr/bin/perl;
package TEST::MyModule;
use strict;
use warnings;
use Fennec::Standalone;
use_ok 'My::Module';
ok( 1, "1 is true" );
is( 1, 1, "1 is 1" );
done_testing();
BRIEF EXPLANATIONS
- package ...
-
Your test must be in a package other than main.
- done_testing()
-
You must call this at the end of your test file.
- Tests in package space
-
Tests can be written directly in package space just like traditional perl testing. By default you get all the tools provided by Test::More, Test::Exception, and Test::Warn.
MORE COMPLETE EXAMPLE
#!/usr/bin/perl;
package TEST::MyModule;
use strict;
use warnings;
use Fennec::Standalone;
use_ok 'My::Module';
# Test Grouping
tests hello_world_group {
ok( 1, "Hello world" );
is( 1, 1, "Hello World" );
}
# RSPEC
describe 'my group' {
before_each { $self->reset }
# 'it()' is an alias to 'tests()'
it 'my test' {
ok( 1, 'spec test!' )
}
# Nested!
describe ...;
}
# Cases
cases some_cases {
case a => sub { ... }
case b => sub { ... }
tests a => sub { ... }
tests b => sub { ... }
}
# Mark a test as todo
TODO {
ok( 0, 'fail' );
} "This will fail, I will fix it later";
# Mark a group as todo (works for skip => '...' as well)
tests not_done => (
todo => "Not done yet",
method => sub {
ok( 0, "This is todo" );
}
);
done_testing();
MORE BRIEF EXPLANATIONS
- Tests in groups
-
tests "hello world group" { ok( $self, 'Automatically get $self' ); ok( 1, "Hello world" ); } tests name { ... }
Tests can be grouped into methods defined with the 'tests' keyword. This uses Devel::Declare magic, $self is automatically given to you. Groups can be run in parrallel improving performance.
- RSPEC like testing
-
describe 'my group' { before_each { $self->reset } # 'it()' is an alias to 'tests()' it 'my test' { ok( 1, 'spec test!' ) } # Nested! describe ...; }
A simple implementation of Ruby's RSPEC.
- Tests under multiple cases
-
You can run the same TestSets under multiple cases using the Case workfow.
cases some_cases { case a => sub { ... } case b => sub { ... } tests a => sub { ... } tests b => sub { ... } }
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2010 Chad Granum
Fennec is free software; Standard perl licence.
Fennec 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.