Test::...tepFile(3pm)

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

πŸ’– 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