0
我有2个场景的Cucumber功能文件,例如:请找到下面的示例文件。来自黄瓜.feature文件的场景未按正确顺序运行
@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类中需要添加什么?
依赖于运行的其他功能之前,通常是不好的做法有特点。尝试捕获您的Given中所需的所有状态,以便它们可以按任何顺序运行。 – jedifans
好的。但是有没有控制这个流程的任何参数?因为我不明白为什么有时它会按顺序运行,有时会平行运行。 – Saisha
您为什么要扩展AbstractTestNG .....类以及实现runCukes方法的任何原因。只要扩大课程范围,就可以省去剩下的课程。看看这个 - http://sahajamit.github.io/Cucumber-JVM-with-TestNG/。或着名的计算示例 - https://github.com/cucumber/cucumber-jvm/tree/master/examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator – Grasshopper