++ed by:
PAVELSR KWAKWA FARACO CKRAS AWNCORP

6 PAUSE users
8 non-PAUSE users.

Erik Huelsmann
and 22 contributors

NAME

Test::BDD::Cucumber::Manual::Integration - Test suite integration options

VERSION

version 0.67

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. Integration with C<prove> which will run your .feature
    files as it does .t files
 2. Creation of a .t file which fires off your selected .feature files
    (Test::Builder integration)

The benefits from using the former approach is that all prove's advanced features like parallel testing, randomized order, --stateful runs, JUnit output, etc., are available out of the box.

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
         --ext=.feature
         --feature-option tags=~@wip
         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
         --ext=.feature
         --feature-option tags=~@wip
         t/

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::TAP;

 # 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. TAP harness prints TAP
 my $harness = Test::BDD::Cucumber::Harness::TAP->new({});

 # For each feature found, execute it, using the Harness to print results
 $executor->execute( $_, $harness ) for @features;

 # Shutdown gracefully
 $harness->shutdown();