【发布时间】:2020-04-14 21:32:42
【问题描述】:
我是黄瓜测试框架的新手。我的目标是使用 Junit 和 Maven 并行运行场景文件。我已按照以下步骤操作:https://cucumber.io/docs/guides/parallel-execution/
我有两个功能文件
功能 1:
Feature: Scenarios feature file One
Scenario: Scenario Number One
When request is sent to fetch data with user one
Then check the result
功能 2:
Feature: Scenarios feature file One
Scenario: Scenario Number Two
When request is sent to fetch data with user two
Then check the result
我还有一个跑步者文件如下:
@RunWith(Cucumber.class)
@CucumberOptions(features = { "classpath:features" },
strict = true,
glue = {"integration.cucumber.step"},
plugin = {"pretty", "html:target/report/cucumber", "json:target/report/cucumber/cucumber.json"},
tags = {"not @Disabled"}
)
public class CucumberTests {
}
我的POM如下:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.12</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
当我通过 mvn clean install 运行黄瓜测试时,两个场景都使用不同的线程运行。 但是我使用创建的运行程序文件(CucumberTests)运行,两者都使用相同的线程运行。如何使用 runner 类让它们以不同的线程运行?
【问题讨论】:
标签: java junit cucumber maven-surefire-plugin