NAME
Test::BDD::Cucumber::Manual::Integration - Test suite integration options
VERSION
version 0.54
DESCRIPTION
How to use Test::BDD::Cucumber in your test suite
OVERVIEW
Test::BDD::Cucumber offers two options to integrate your tests with your test framework:
1. Creation of a .t file which fires off your selected .feature files
(Test::Builder integration)
2. Integration with C<prove> which will run your .feature
files as it does .t files
The benefits from using the latter approach is that all prove
's advanced features like parallel testing, randomized order, --state
ful runs, etc are also available without efforts of the test developer.
Test::Builder integration -- a documented example
The code below needs to be stored in a .t
file in the t/
or xt/
directory. When done that way, the tests are integrated into make test
as generated from make test
after perl Makefile.PL
.
#!perl
use strict;
use warnings;
# This will find step definitions and feature files in the directory you point
# it at below
use Test::BDD::Cucumber::Loader;
# This harness prints out nice TAP
use Test::BDD::Cucumber::Harness::TestBuilder;
# Load a directory with Cucumber files in it. It will recursively execute any
# file matching .*_steps.pl as a Step file, and .*\.feature as a feature file.
# The features are returned in @features, and the executor is created with the
# step definitions loaded.
my ( $executor, @features ) = Test::BDD::Cucumber::Loader->load(
't/cucumber_core_features/' );
# Create a Harness to execute against. TestBuilder harness prints TAP
my $harness = Test::BDD::Cucumber::Harness::TestBuilder->new({});
# For each feature found, execute it, using the Harness to print results
$executor->execute( $_, $harness ) for @features;
# Shutdown gracefully
$harness->shutdown();
prove integration
With Test::BDD::Cucumber installed in the Perl search path (PERL5LIB) comes the possibility to run the .feature files with a prove
command directly, by specifying
$ prove -r
--source Feature
--feature-option extensions=.feature
--feature-option tags=~@wip
--ext=.feature
t/
This command registers a prove
plugin named Feature
associated with the .feature
extension. Additionally, it passes a tag filter to exclude @wip tagged features and scenarios from being run.
When executed, the command searches the t/
directory recursively for files with the .feature
extension. For each directory holding at least one .feature
file, the step files are loaded from the step_definitions/
subdirectory.
The command above will find and run only .feature
files. When you want to run your regular .t
files as well as Test::BDD::Cucumber's .feature
files, run the following command:
$ prove -r --source Perl --ext=.t
--source Feature
--feature-option extensions=.feature
--feature-option tags=~@wip
--ext=.feature
t/