Cucumber .feature 文件中的场景未按正确顺序 运行

Scenarios from cucumber .feature file are not running in proper sequence

我有包含 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 运行ner class 中添加什么?

  1. 无需将 cukes runner 标记为 @Test,扩展 AbstractTestNGCucumberTests 就足够了
  2. 无需在此 class 中定义测试,使用步骤 classes 和功能文件
  3. 如果您需要某些先决条件,请考虑在您的步骤中使用 @Before 注释 classes 使用关键字 Background 在你的特征文件中。 Background 部分中描述的句子将针对该功能文件中的每个场景执行。像这样:

    Background: Test xyz feature
    Given The user is on login page
    When User enters credentials
    And clicks on login button
    Then homepage should be displayed
    
    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