Test::More::Behaviour - BDD module for Perl
$ cpan -i Test::More::Behaviour
describe 'Bank Account' => sub {
context 'transferring money' => sub {
it 'withdrawals amount from the source account' => sub {
my $source = BankAccount->new(100);
my $target = BankAccount->new(0);
$source->transfer(50, $target);
is($source->balance, 50);
};
it 'deposits amount into target account' => sub {
my $source = BankAccount->new(100);
my $target = BankAccount->new(0);
$source->transfer(50, $target);
is($target->balance, 50);
};
};
};
Test::More::Behaviour is a Behaviour-Driven Development module for Perl programmers. It is modeled after Rspec http://rspec.info the infamous BDD tool for Ruby programmers.
Because Test::More::Behaviour uses Test::More as its 'base', you can treat every Test::More::Behaviour test as if it were Test::More!
This project is built with the philosophy that 'Tests are the Documentation'. For a full set of features, please read through the test scenarios.
Used to group a set of examples of a particular behaviour of the system that you wish you describe.
An example to run.
Used to further establish deeper relations for a set of examples. This is best used when several examples have similar interactions with the system but have differring expectations.
Used to define code which executes before and after each example or only once per example group.
The source code for Test::More::Behaviour can be found at https://github.com/bostonaholic/test-more-behaviour
Currently, each it
will not run as a Test::More::subtest. This is because the coloring was not working correctly because subtest needed the description before evaluating the block passed in. If you can fix this, please submit a github pull request and I will take a look.
If you do find any bugs, please send me an email or send me a github pull request with a broken test (and your fix if you're able to) and I will be more than happy to fix.
IO::Capture::Stdout (test only)
Matthew Boston <matthew DOT boston AT gmail DOT com> with special thanks to Dustin Williams.
Copyright (c) 2011 Matthew Boston. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
I assume no responsibility if this documentation is incorrect or outdated. The tests are fully documenting of this software.