Details
-
Type: Story
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
I would like know to know in Jbehave framework that, how we could map the Scenario(from Story file) to data in data file(External file) in Jbehave.
Generally, each Scenarios will have some set of parameter in story file and mapping data will be available in data file as mentioned below.
Scenario: Login1: User Logs into the Application
Given I log into Application as user <username>
with password <password>
Examples:
../Login.table
Login.table
-----------
username | password |
ABC | xxx |
Scenario: Login2: User Logs into the Application with incorrect password
Given I log into Application as valid user <username> with invalid password <password>
Examples:
../Login1.table
Login1.table
------------
username | password |
ABC | invalidpassword |
The above one looks like one to one mapping, means each scenario should have separate data file.
I would like to keep all the data's in one data file itself by having scenario mapping in story file and data file.
Below one illustrates the scenario mapping in story file and table file
It can be easy to maintain the data's in data file without affecting the actual story file, if i get the solution for this.
Login.story
-----------
Scenario: Login1: User Logs into the Application
Given I log into Application as user <username>
with password <password>
Examples:
/Login.table
Scenario: Login2: User Logs into the Application with incorrect password
Given I log into Application as valid user <username> with invalid password <password>
Examples:
/Login.table
Login.table
-----------
Scenario: +Login1
username | password |
ABC | xxx |
Scenario: +Login2
username | password |
ABC | invalidpassword |
Hi, you can use a single file to contain the table data for each example, but what you cannot do is use a single file to hold all the tables for all your examples.
The added complexity of the double parsing (once for the story and once for the table file) would also need to weighted against the loss of readability and communication effectiveness.
The principle of BDD is that the story should be expressed in plain text and easily comprehensible by all stakeholders and team members. Already, expressing the data expressed in a separate file deviates slightly from this principle of readability but has the reminding feature of simplicity and force the scenario writer to use appropriately named files for the table data.
Having all the examples tables contained in a single file does not seem very useful nor effective because the examples table is an integral part of the scenario, and can only be fully understood by the proximity to the scenario steps.