Test::...ration(3pm)

πŸ“¦
version 0.87 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Test::BDD::Cucumber::Manual::Integration β€” aka the Test suite integration options page, straight outta the User Contributed Perl Documentation (3pm) crew. Bestie, this is your guide to making Cucumber-ish tests play nice with your test suite. πŸ₯’βœ¨


🌸 VERSION 🌸

version 0.87 β€” yes queen, that's the one. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

How to use Test::BDD::Cucumber in your test suite. That's it, that's the whole vibe. 🫢


✨ OVERVIEW ✨

So Test::BDD::Cucumber gives you two whole options for integrating your tests with your test framework, and honestly? Both are valid:

  1. Integration with 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 (the Test::Builder integration) πŸ”₯

The benefits from using the former approach (the prove one, the first one, keep up bestie) is that all of prove's advanced features β€” like parallel testing, randomized order, --stateful runs, JUnit output, etc. β€” are available out of the box. No extra setup, no cap. πŸ‘‘


πŸ“ prove integration

With Test::BDD::Cucumber installed in the Perl search path (PERL5LIB), you unlock 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. Not me excluding the work-in-progress stuff, iconic behaviour honestly. πŸ™ˆ

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. So it just finds them, iykyk. 🧚

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/

Two sources, two extensions, one command. Slay. πŸ’…


🌈 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. So like... put it where it belongs and the whole machine just works, bestie. ✨

#!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();
Notice the shutdown() at the end β€” shut down gracefully, bestie, always. πŸŽ€

That's the whole page, no filler, all facts intact. This cutie was brought to you by perl v5.40.1, dated 2025-05-29, and it lives under the name Test::...ration(3pm) in the User Contributed Perl Documentation set. Go forth and integrate, you main character. πŸ‘‘πŸ’–πŸ¦‹

πŸ“¦ where this page comes from