Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

test::bdd::cucumber::stepfile(3pm) [debian man page]

Test::BDD::Cucumber::StepFile(3pm)			User Contributed Perl Documentation			Test::BDD::Cucumber::StepFile(3pm)

NAME
Test::BDD::Cucumber::StepFile - Functions for creating and loading Step Definitions VERSION
version 0.11 DESCRIPTION
Provides the Given/When/Then functions, and a method for loading Step Definition files and returning the steps. SYNOPSIS
Defining steps: #!perl use strict; use warnings; use Test::More; use Test::BDD::Cucumber::StepFile; use Method::Signatures; # Allows short-hand func method Given 'something', func ($c) { print "YEAH!" } When qr/smooooth (d+)/, func ($c) { print "YEEEHAH $1" } Then qr/something (else)/, func ($c) { print "Meh $1" } Step qr/die now/, func ($c) { die "now" } Loading steps, in a different file: use Test::BDD::Cucumber::StepFile; my @steps = Test::BDD::Cucumber::StepFile->load('filename_steps.pl'); EXPORTED FUNCTIONS
Given When Then Step Accept a regular expression or string, and a coderef. Some cute tricks ensure that when you call the "load()" method on a file with these statements in, these are returned to it... load Loads a file containing step definitions, and returns a list of the steps defined in it, of the form: ( [ 'Given', qr/abc/, sub { etc } ], [ 'Step', 'asdf', sub { etc } ] ) AUTHOR
Peter Sergeant "pete@clueball.com" LICENSE
Copyright 2011, Peter Sergeant; Licensed under the same terms as Perl perl v5.14.2 2012-05-20 Test::BDD::Cucumber::StepFile(3pm)

Check Out this Related Man Page

Test::BDD::Cucumber::Manual::Steps(3pm) 		User Contributed Perl Documentation		   Test::BDD::Cucumber::Manual::Steps(3pm)

NAME
Test::BDD::Cucumber::Manual::Steps - How to write Step Definitions VERSION
version 0.11 INTRODUCTION
The 'code' part of a Cucumber test-suite are the Step Definition files which match steps, and execute code based on them. This document aims to give you a quick overview of those. STARTING OFF
Most of your step files will want to start something like: #!perl use strict; use warnings; use Test::More; use Test::BDD::Cucumber::StepFile; use Method::Signatures; The fake shebang line gives some hints to syntax highlighters, and "use strict;" and "use warnings;" are hopefully fairly standard at this point. Most of my Step Definition files make use of Test::More, but you can use any Test::Builder based testing module. Your step will pass its pass or fail status back to its harness via Test::Builder - each step is run as if it were its own tiny test file, with its own localized Test::Builder object. Test::BDD::Cucumber::StepFile gives us the functions "Given()", "When()", "Then()" and "Step()". These pass the step definitions to the class loading the step definitions, and specify which Step Verb should be used - "Step()" matches any. Method::Signatures allows us to use a small amount of syntactic sugar for the step definitions, and gives us the "func()" keyword you'll see in a minute. STEP DEFINITIONS
Given qr/I have (d+)/, func ($c) { $c->stash->{'scenario'}->{'count'} += $1; } When "The count is an integer", func ($c) { $c->stash->{'scenario'}->{'count'} = int( $c->stash->{'scenario'}->{'count'} ); } Then qr/The count should be (d+)/, func ($c) { is( $c->stash->{'scenario'}->{'count'}, $c->matches->[0], "Count matches" ); } Each of the exported verb functions accept a regular expression (or a string that's used as one), and a coderef. The coderef is passed a single argument, the Test::BDD::Cucumber::StepContext object. To make this a little prettier, we use Method::Signatures's "func()" keyword so we're not continually typing: "sub { my $c = shift; ... ". We will evaluate the regex immediately before we execute the coderef, so you can use $1, $2, $etc, although these are also available via the StepContext. NEXT STEPS
How step files are loaded is discussed in Test::BDD::Cucumber::Manual::Architecture, but isn't of much interest. Of far more interest should be seeing what you have available in Test::BDD::Cucumber::StepContext... AUTHOR
Peter Sergeant "pete@clueball.com" LICENSE
Copyright 2011, Peter Sergeant; Licensed under the same terms as Perl perl v5.14.2 2012-05-20 Test::BDD::Cucumber::Manual::Steps(3pm)
Man Page