views:

248

answers:

2

I've got to test a message-routing application, whose functionality is broadly as follows: - message gets sent to app - app examines message - message gets forwarded somewhere, based on the content of the message

The vast majority of test cases are near-identical; generate a particular type of message, load it into the system, wait a few seconds, then check the required destination to ensure that the message was forwarded correctly.

Rather than generate 100s of near-identical test cases in Cucumber, is there a recommended way to generate the one test case, and have it repeatedly cycle through all the (message, required_destination) tuples? I'd prefer to have these tuples maintained into a YAML file rather than a database, for ease of maintenance, but either solution would be fine.

A: 

I dont have this kind of situation in cucumber, but I do use pipe separated files in specs for massive data testing, hope it will help:

You can find examples here in description of DamerauLevenshteinMod and here in read_test_file

I dont see why the same approach cannot be used for cucumber as well.

dimus
Thanks Dimus. I can think of a number of possible ways of doing it - for that matter, having code walk through my YAML file and write a new Cucumber scenario for each message type would work just fine - but I'm primarily interested to find out if there's a Cucumber "native" or "recommended" way of achieving it.
monch1962
+2  A: 

You should try Scenario Outline using Examples

Normal Scenario

Scenario: Login
  Given I am on login page
  When I enter username "Jonas" and password "secrect" and press login
  Then I get redirected to "Jonas Home Page"

Scenario Outline

Scenario Outline: Login
  Given I am on login page
  When I enter username <username> and password <password> and press login
  Then I get redirected to <redirect_page>

Examples:
  | username | password | redirect_page     |
  | "Jonas"  | "secret" | "Jonas Home Page" |
  | "Anna"   | "Data"   | "Annas Home Page" |

Read More: http://wiki.github.com/aslakhellesoy/cucumber/scenario-outlines

Jonas Söderström