Data-driven tests in Cucumber
-
20-09-2019 - |
Question
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.
Solution
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: https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
OTHER TIPS
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.