Cucumber JVM 4.0.0 和 Junit 测试运行程序不会发生并行执行

我无法使用 cucumber JVM 4.0.0 和 Junit testrunner 并行运行功能。我只打开了一个浏览器实例,一旦执行完成,浏览器将关闭并再次打开以执行下一个功能。根据我在 Maven surefire 中的线程数为 3,我希望同时打开 3 个浏览器实例以运行 3 个功能。我已经按照以下链接进行操作,但仍然没有成功。功能一个接一个地运行。我已经为 DI 使用了 Pico 容器。我点击了这个链接用于更新不同版本的 Surefire 插件,但仍然没有运气。我已经为 IO.cucumber Jars 尝试了 4.0.0 和 4.2.0。我尝试了从 2.19 到 2.22 的不同版本的 surefire,但仍然没有运气。我有 3 个功能文件,每个文件都有一个标记为“@Parallel”的场景大纲。我不确定哪里出错了。我尝试过并行Surefire 插件中的“两者”和“方法”。我的 Junit 版本是 4.12。

我的测试程序如下。


import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;


@RunWith(Cucumber.class)

@CucumberOptions(plugin = {"html:target/cucumber-html-report",

"json:target/cucumber.json","pretty:target/cucumber-pretty.txt",

"usage:target/cucumber-usage.json, "junit:target/cucumber-results.xml"},

features={"src/test/resources/featuresfiles"},strict=false,dryRun=false,

glue={"Stepdef_new.stepdefinitions"},

tags={"@Parallel"}

}


Public class TestRunner{

}    


红糖糍粑
浏览 161回答 3
3回答

绝地无双

您可以尝试删除 testng 依赖项或明确说使用surefire-junit<plugins>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.plugins</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>maven-surefire-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>${surefire.version}</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <parallel>methods</parallel>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <threadCount>20</threadCount>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!-- <useUnlimitedThreads>true</useUnlimitedThreads> -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <include>**/JUnitRunner.java</include>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </includes>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <dependencies>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <!-- https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - You can also manually force a specific provider by adding it as a dependency&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; to Surefire itself: -->&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.apache.maven.surefire</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>surefire-junit47</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>${surefire.version}</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dependencies>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </plugins>试试这个: https ://github.com/rhapsodyman/cucumber4-parallel

慕妹3146593

这可能无关紧要。我尝试使用 Junit 实现 Cucumber,因为它在功能级别上并行的限制,所以我搬到了 Cucumber-TestNG。TestNG 它自己支持 Junit。所以在当前设计中只需要改变跑步者类请看一下这个https://github.com/bhargavQA/selenium-java-cucumber-framewrok.git这是通过Cucumber TestNG完成的,并支持场景级别的并行执行。

jeck猫

您应该使用 maven-failsafe-plugin,而不是万无一失。我将故障安全与 com.github.temyers -cucumber-jvm-parallel-plugin 结合使用
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java