Reputation: 771
Is there a way to reuse cucumber scenarios across multiple features which each share the same UI characteristics?
For example if I am creating an iPhone app then I would have certain tests that I would like to run for each table view screen regardless of what is actually being displayed. These would be add a new row, delete a row, reorder etc.
Copying and pasting these into each feature breaks DRY. Is there a way to specify generic or templated tests in cucumber which I can include into each features that requires them?
Upvotes: 2
Views: 239
Reputation: 17602
Don't think of BDD as testing. Think of it as providing a set of examples which show why your app is valuable and how you can use it.
If the app uses the same code for each table, all you need is one example. I would expect it to be phrased something like:
Given Quentin has three films listed
When he adds "Kill Bill" to the film list
Then he should be reminded that he already owns it.
Given Quentin has mistakenly added "Twilight" to his favourite films
When he deletes it from the film list
Then it should no longer be in the table.
The more interesting and human you can make the scenarios, the more you'll be able to work out why your application is valuable. That's the real heart of BDD - not testing, but knowing why you're writing the code in the first place.
Talking to people who really want the app will help you find out what it should do - and if you're writing it on your own, buy a rubber duck!
Upvotes: 1