Is there any way to skip Background step for some scenarios in cucumber feature using any annotatati

3,094 views
Skip to first unread message

Sreedhar sree

unread,
Nov 3, 2016, 5:53:28 AM11/3/16
to Cukes
Hi Guys,

I'm trying to find out a way to skip  Background step for some scenarios in cucumber feature using any annotations, Since some of my scenarios in between are doing Data Base related operations, those scenarios no need to be require Background step. 

Issues:

1. I can't place the scenarios which doesn't require Background on top of Background, because functional requirement is like that.
2.I can't execute Background for all scenarios, because it will take more time.

Finally I want to skip Background step for some scenarios in cucumber feature using any annotations, if there is any way for doing this please let me know.

Roberto Lo Giacco

unread,
Nov 9, 2016, 1:23:11 PM11/9/16
to Cukes
Short answer: you shouldn't even try, simply move your scenarios in a separate feature file.

Long answer: your code should reflect what has been described in the feature file, what you are looking for is a trick to cheat on your specifications, which completely destroys the purpose of BDD.

If your problem is about the duration of your background execution than you should tackle that. From what I can guess your background seems more like a test rig setup, which shouldn't be described as a background. 

Also I don't understand your first bulletpoint: there is no specific meaning to the scenario ordering and relying on scenario order is something I would strongly discourage. 
The only meaning you should associate to scenario order is ease of reading: talking about how the user deletes an entity is sometimes easier to read if you first describe how the user creates one, but you should NEVER rely on the order. If a business person starts reordering your scenarios because he/she believes they are easier to read in another order, that must have no impact on your scenario execution.

Don't use Cucumber as a replacement for JUnit: IT ISN'T.


Reply all
Reply to author
Forward
0 new messages