Breaking long lines in feature files

3,634 views
Skip to first unread message

Dimitar G

unread,
Nov 7, 2013, 9:43:11 AM11/7/13
to cu...@googlegroups.com
Hi,

I have some feature files where scenario steps often times will exceed 100 characters.
I would like to be able and split the scenario step description into several lines, so it is easier to read.

Is this possible and if Yes, how do you do it?

Thanks,

Dimitar

PS Quick search on the subject did not give me anything.

Matt Wynne

unread,
Nov 7, 2013, 9:58:34 AM11/7/13
to cu...@googlegroups.com
Hi Dimitar
There's no way to do this that I know of. Can you show us a real example? It sounds pretty crazy!


Dimitar G

unread,
Nov 7, 2013, 2:05:38 PM11/7/13
to cu...@googlegroups.com
Hi Matt,

Below is snippet from one of my features.
The Given line is in excess of 100 characters.

Best regards,

Dimitar


Feature: Delete encounters from main screen
    As an user I want to be able to select one or more encounters and delete them

Background:
    Given   the following encounters exist, based on template "delete-test" for TOT "features/mainscreen/TEST.xml":
    |       create_date     |
    |   20130101 00:00:00   |
    |   20131231 00:00:00   |
    |   20130731 00:00:00   |
    And     the main screen is displayed
...

Paolo Ambrosio

unread,
Nov 7, 2013, 4:13:45 PM11/7/13
to cu...@googlegroups.com
On Thu, Nov 7, 2013 at 7:05 PM, Dimitar G <dimitar.g...@gmail.com> wrote:

> Hi Matt,
>
> Below is snippet from one of my features.
> The Given line is in excess of 100 characters.

Are you sure Cucumber is the right tool for that kind of test? It is
supposed to facilitate communication between stakeholders and the
development team, but your tests look more technical than
business-oriented.

Marty Bradley

unread,
Nov 7, 2013, 5:02:32 PM11/7/13
to cu...@googlegroups.com
Dimitar,

Do you need the --  based on template "delete-test" for TOT "features/mainscreen/TEST.xml" portion of the Given to narrow down the selection criteria of the Given?  Or is this something that should be known by the programmer or tester as part of the "Given the following encounters exist"?




--
-- Rules --

1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.

You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Marty Bradley
Enterprise Agile Coach
(703) 869-2217
http://www.linkedin.com/in/martybradley
Click to scan contact information

Dimitar G

unread,
Nov 8, 2013, 6:09:46 AM11/8/13
to cu...@googlegroups.com
Hi,

All terms used in the feature are from the business domain and relate to entities that the end user will work with.
The portions in quotes are parameters to the step definition. The step itself " Given   the following encounters exist..." represents something that the end user understands.
So Yes, they are needed.

I could remove them and make them part of the step definition instead, but then if a tester (not a developer) is looking at the feature, the tester will have to go and look through the code in order to see how the test is being prepared for execution.
Our testers are not necessarily developers, and asking them to look through maybe something they do not have a burning desire to do.
Also, that will make re-using the step in other features more difficult.

Best regards,

Dimitar

Matt Wynne

unread,
Nov 8, 2013, 6:30:39 PM11/8/13
to cu...@googlegroups.com
Hi Dimitar
Obviously I have no idea what these terms mean, and as I see you've said in replies to others, all this information is valuable to your readers. 

My suggestion is to break the work over multiple steps. So for example could you do this?

Background:
  Given TOT "features/mainscreen/TEST.xml"
  And template "delete-test"
  And the following encouters:
    | create_date |
    | ...





--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dimitar G

unread,
Nov 9, 2013, 9:59:54 AM11/9/13
to cu...@googlegroups.com
Hi Matt,
 
> My suggestion is to break the work over multiple steps. So for example could you do this?

Something like that will probably work, if nothing else, but the quoted strings may/will have to be repeated in the subsequent steps.
The reason is - quoted strings refer to entities that have dependencies between each other.
Step definitions do not maintain state, so the only way really to account for the dependencies is to pass them as parameters.

Best regards,

Dimitar

Matt Wynne

unread,
Nov 9, 2013, 10:49:52 AM11/9/13
to cu...@googlegroups.com
On 9 Nov 2013, at 14:59, Dimitar G <dimitar.g...@gmail.com> wrote:

Step definitions do not maintain state

Yes they do. You just set an instance variable.

Dimitar G

unread,
Nov 10, 2013, 6:51:22 AM11/10/13
to cu...@googlegroups.com
We tried that and things started going in this direction:
https://github.com/cucumber/cucumber/wiki/Feature-Coupled-Step-Definitions-%28Antipattern%29

Best regards,

Dimitar

Reply all
Reply to author
Forward
0 new messages