Allow multiple arguments for Feature(...) and reusable step functions with regular expressions

Description

Feature function receive variable arguments to avoid so many levels of nesting. The code looks more like Gherkin where reusable steps could easily be defined and executed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 // step functions may be defined in other file. dimensionsSteps.cfc? step("/^(I have )?a width of ([0-9]+)$/", function( ignore_param, value ){ width = value; } ); step("/^(I have )?a height of ([0-9]+)$/", function( ignore_param, value ){ height = value; } ); step("/^(I have )?a depth of ([0-9]+)$/", function( ignore_param, value ){ depth = value; } ); step( "/^the result should be ([0-9]+)$/", function( result_expected ){ expect( myObject.myFunction( width, height, depth ) ).toBe( result_expected ); } ) feature( "As a distribution manager, I want to know the volume of the box I need", Given( "I have a width of 20" ), And( "a height of 30" ), And( "a depth of 40" ), When( "I run the calculation" ), Then( "the result should be 24000" ) }); feature( "As a distribution manager, the volumen of the box should has a minimum (1)", Given( "I have a width of 2" ), And( "a height of 3" ), And( "a depth of 4" ), When( "I run the calculation" ), Then( "the result should be 24" ) }); feature( "As a distribution manager, the volumen of the box should has a minimum (10)", Given( "I have a width of 2" ), And( "a height of 1" ), And( "a depth of 1" ), When( "I run the calculation" ), Then( "the result should be 10" ) });

https://cucumber.io/docs/cucumber/step-definitions/

Status

Assignee

Luis Majano

Reporter

David Moreno Fernández

Labels

Priority

Major
Configure