I have a couple of Specflow's features file which contain multiple scenarios and I want to execute them against multiple environments (DEV, TEST, and SIT).
So, my question here is - what is the best way to pass environment specific data from feature file to step definition. As you can see in the example below employee records are different in each environment.
Scenario Outline: Employee Search
Given Application is logged
And Search for employee record with <EmployeeName>, <EmployeeID>, <Company>, <Designation> and <Environment>
Examples:
| EmployeeName| EmployeeID| Company | Designation | Environment |
| John Smith 1| 123 | ABC | Analyst | DEV |
| John Smith 2| 456 | DFG | Manager | TEST |
| John Smith 3| 789 | XYZ | Sr Analyst | SIT |
[When(@"Search for employee record with (.*), (.*), (.*), (.*) and (.*)")]
public void WhenSearchEmployee (string EmployeeName, string EmployeeID, string Company, string Designation, string Environment)
{
if (Environment== "DEV")
{
EmployeeRecord.SearchEmployee(EmployeeName, EmployeeID, Company, Designation);
}
else if (Environment== "TEST")
{
EmployeeRecord.SearchEmployee(EmployeeName, EmployeeID, Company, Designation);
}
else if (Environment== "SIT")
{
EmployeeRecord.SearchEmployee(EmployeeName, EmployeeID, Company, Designation);
}
}
Edits
- I'm identifying the environment with
app.config
file
Basically, I want to execute the same test case in multiple environments (one at a time) with different data. Also if I have two rows in examples
table, how to execute only once based on the environment.
Is this the right approach? Thanks.