I have a background test case with tags which I need to run everytime with mutliple scenarios .
Example :
There are 3 scenarios and 1 background. In short, Background should behave like @BeforeMethod of testing
So my execution should be like
- Background then Scenario1 (@Dev,@tagteacher1)
- Again Background then Scenario2 (@Dev,@tagteacher2)
- Again Background then Scenario3 (@Dev,@tagteacher3)
@TestStory
Feature: Teachers' timesheet need to be filled
Background:
Scenario Outline: Open Webpage
Given User Open teacher application with given <ENDPOINT>
And Login into application with given <USERNAME> and <PASSWORD>
And User clicks on teacher submission link
@DEV
Examples:
| endpoint | USERNAME | PASSWORD |
| http://teachersheetdev.ggn.com | sdrdev| aknewdev|
@QA
Examples:
| endpoint | USERNAME | PASSWORD |
| http://teachersheetqa.ggn.com | sdrqa | aknewdev|
@tagteacher1
Scenario1: Open app home page and click the button1
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
@tagteacher2
Scenario1: Open app home page and click the button2
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
@tagteacher3
Scenario1: Open app home page and click the button3
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
import org.junit.runner.RunWith;
import com.optum.synergy.common.ui.controller.WebController;
import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = { "json:target/test_results/cucumber.json"},
features = { "src/main/resources/ui/features" },
tags ={"@Dev,@tagteacher"},
snippets = SnippetType.CAMELCASE
)
public class CucumberRunnerTest {
public static void tearDown(){
WebController.closeDeviceDriver();
}
}
How to use tag when I want to run with Dev or QA env?