我有 2 个场景的 Cucumber 功能文件,例如,请在下面找到示例文件。
@RunFeature
Feature: Sanity Testing of scenarios
@LoginFeature
Scenario: Test xyz feature
Given The user is on login page
When User enters credentials
And clicks on login button
Then homepage should be displayed
@InfoFeature
Scenario: Test abc feature
Given The user is on home page
When User enters employee name in textbox
And clicks on get details button
Then Employee details are displayed
我正在尝试使用 TestNG 运行此功能文件,
package TestNGClass;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import cucumber.api.testng.TestNGCucumberRunner;
@Test(groups="cucumber")
@CucumberOptions(
features ="src/main/resources",
glue="stepDefinitions",
tags="@RunFeature")
public class TestNGRunner extends AbstractTestNGCucumberTests{
@Test(groups="cucumber",description="Runs Cucumber Features")
public void run_Cukes()throws IOException{
//new TestNGCucumberRunner(getClass()).runCukes();
}
}
但我观察到,有时它会并行运行两种场景,有时会以顺序模式运行。我正在尝试以顺序模式运行场景。谁能告诉我需要在我的 testng runner 类中添加什么?