Test::...tepFile(3pm)
π NAME π
Test::BDD::Cucumber::StepFile β bestie, this is where all the functions live that build and load your Step Definitions π
β¨ VERSION β¨
version 0.87 β that's the one, that's the girl π
πΈ DESCRIPTION πΈ
Okay so, this module is literally the plug π. It hands you the Given/When/Then functions, plus a method that loads your Step Definition files and gives you back all the steps. That's it. That's the whole vibe. Periodt. π
π¦ SYNOPSIS π¦
Not me defining steps π
#!perl
use strict; use warnings; use Test::More;
# or: use strict; use warnings; use Test2::V0;
use Test::BDD::Cucumber::StepFile;
Given 'something', sub { print "YEAH!" }
When qr/smooooth (\d+)/, sub { print "YEEEHAH $1" }
Then qr/something (else)/, sub { S->{'match'} = $1 }
Step qr/die now/, sub { die "now" }
Transform qr/^(\d+)$/, sub { int $1 }
Before sub { setup_db() }
After sub { teardown() }
And loading steps, in a totally different file π§
use Test::BDD::Cucumber::StepFile;
my @steps = Test::BDD::Cucumber::StepFile->load('filename_steps.pl');
π EXPORTED FUNCTIONS π
Given
When
Then
Step
Transform
Before
After
Each one takes a regular expression or a string, plus a coderef. And here's the cute lil trick πͺ β there's some sneaky magic in place so that when you call the load() method on a file that has these statements in it, these are the things that get handed back to it. It's giving "how did she do that". Iconic.
C
S
These give you back the context and the Scenario stash respectively. BUT. π¨ Only when you call them from inside a step definition. Anywhere else and it's not the move, bestie.
load
Loads a file full of step definitions, and returns a list of all the steps defined inside it, looking exactly like this:
(
[ 'Given', qr/abc/, sub { etc } ],
[ 'Step', 'asdf', sub { etc } ]
)
π AUTHOR π
Peter Sergeant pete@clueball.com β the original main character π«Ά
π LICENSE π
Copyright 2019-2023, Erik Huelsmann
Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl
okay and that's a wrap bestie, this page came to you from perl v5.40.1 dated 2025-05-29 and honestly? ate. no cap. bye mwah πβ¨
π¦ where this page comes from
- debian trixie: libtest-bdd-cucumber-perl 0.87-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-bdd-cucumber-perl 0.87-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-bdd-cucumber-perl 0.87-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms