Maven/Junit 并行执行 - Cucumber-JVM v4.0.0

2024-05-25

我正在努力获取与 JUnit/Maven 一起使用的 Cucumber-JVM v4.0.0 的新并行执行功能。

作为指定here https://github.com/cucumber/cucumber-jvm/tree/v4.0.0/junit,如果您配置<parallel> and <threadCount>相应地在你的 POM 中,并使用依赖注入来共享状态(我正在使用 Pico Continer),那么你的 Cucumber 功能应该并行执行。

然而,当我运行 Maven 时,它仍然一次只执行一项功能。

我在下面包含了完整的 POM - 有人可以帮忙吗?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.softwareautomation</groupId>
<artifactId>selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>selenium</name>
<url>http://maven.apache.org</url>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12.4</version>
            <configuration>
                <parallel>both</parallel>
                <threadCount>4</threadCount>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>

    <!-- AssertJ -->
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.11.1</version>
        <scope>test</scope>
    </dependency>

    <!-- Cucumber -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>4.0.0</version>
        <scope>test</scope>
    </dependency>

    <!-- JUnit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

    <!-- Selenium WebDriver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.11.0</version>
    </dependency>

</dependencies>

如果有帮助,下面是我的运行程序类(com.softwareautomation.world 是 DI 类)

package com.evasoftwareautomation.runners;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        plugin = {"pretty", "html:target/cucumber", "junit:target/cucumber.xml"},
        features = "src/test/resources/com/softwareautomation/features",
        glue = {"com.softwareautomation.stepdefs", "com.softwareautomation.world"},
        junit ={ "--step-notifications"},
        monochrome = true)
public class CucumberTest {
}

请参阅下面从 Maven 运行时失败的堆栈跟踪:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Concurrency config is parallel='methods', perCoreThreadCount=true, threadCount=4, useUnlimitedThreads=false
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.NullPointerException
        at org.junit.runner.Description.createSuiteDescription(Description.java:124)
        at org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207)
        at org.junit.runners.ParentRunner.shouldRun(ParentRunner.java:434)
        at org.junit.runners.ParentRunner.filter(ParentRunner.java:382)
        at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
        at org.junit.runners.ParentRunner.filter(ParentRunner.java:384)
        at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
        at org.junit.runners.ParentRunner.filter(ParentRunner.java:384)
        at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
        at org.junit.runners.ParentRunner.filter(ParentRunner.java:384)
        at org.junit.runner.manipulation.Filter.apply(Filter.java:97)
        at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
        at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
        at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
        ... 9 more

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.709 s
[INFO] Finished at: 2018-10-25T23:36:01+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project selenium: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

at org.apache.maven.surefire.common.junit48.FilterFactory$GroupMatcherCategoryFilter.shouldRun(FilterFactory.java:207)

您正在使用 JUnit 4.12。然而,如上所述,堆栈跟踪告诉我们,surefire 正在尝试使用 JUnit 4.8 的集成。您的 Surefire 版本于 2012 年发布,而 JUnit 4.12 于 2014 年发布。您是否考虑过更新您的 Maven Surefire 插件?

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Maven/Junit 并行执行 - Cucumber-JVM v4.0.0 的相关文章

随机推荐

  • 从 javascript 访问 JSF 资源

    我想访问 JSF 资源 在WebPages resources img 来自 JavaScript 函数 例如 function hideSpinner arguments i poster img sppiner png 我努力了argu
  • 动态添加 TextView - Android

    如何动态添加 TextView 到此 注释掉的代码不起作用 public class myTextSwitcher extends Activity private TextView myText public myTextSwitcher
  • 为什么方法引用不跟踪这一点?

    我正在使用 Babel 来转译 ES2015 类 class Foo constructor foo this foo foo sayFoo console log this foo 如果我说这样的话 这个课程的效果就完全符合我的预期foo
  • Ada:用可变大小的数组打包记录

    我正在寻找创建一个打包记录 它可以容纳长度从 5 50 个元素不等的数组 是否可以以这样的方式来完成此操作 以便可以在不浪费空间的情况下打包记录 当我去创建记录时 我会知道数组中有多少元素 the range of the array ty
  • 获取数组中从右上角到左下角的所有对角线

    我试图存储矩阵中从右上角到左下角的所有对角线 并将它们存储在一个数组中 matrix array 2 0 0 2 3 0 0 3 3 0 0 2 0 0 0 0 预期产出 2 0 3 0 0 2 2 0 0 0 3 0 0 3 0 0 我试
  • JDK 8 - “无法解析类型 java.util.Map$Entry”[重复]

    这个问题在这里已经有答案了 我尝试使用 HashMap 但收到错误 无法解析类型 java util Map Entry 它是从所需的 class 文件间接引用的 我正在使用 JDK 8 和 Eclipse 有人知道为什么吗 My code
  • 脚本参数不支持 ElasticSearch v7.3 更新脚本中的 START_ARRAY 类型的值

    我正在尝试更新索引文档 但通过 Postman 更新 API 脚本时出现以下错误 error root cause type x content parse exception reason 5 15 script params doesn
  • 更改数组键而不更改顺序

    You can 更改 数组元素的键 https stackoverflow com questions 240660 in php how do you change the key of an array element只需设置新密钥并删
  • 插入特殊字符

    我试图在我的 Cassandra 表中插入特殊字符 但无法插入 无法在带有变音符号的表中插入数据 https stackoverflow com questions 17425262 inserting data in table with
  • Kotlin:如何修改对中的值? [复制]

    这个问题在这里已经有答案了 为什么我无法更改该对中的值 var p Pair
  • 未在 OpenERP 7 中呈现

    我正在使用 OpenERP 7 我想修改我的发票报告页脚以显示当前页面和总页数 如下所示 页数 第一页的 1 2 以及 页数 第二页2 2 这是我的代码
  • 如何在 Windows 窗体中制作窗体模式?

    我正在尝试创建一个子表单 帮助用户在父表单中的字段中输入数据 我希望这个子表单是模态的 但是我需要做什么才能使这个表单成为模态 我需要使用其他类型的物品吗 Use Form ShowDialog http msdn microsoft co
  • Kubernetes 基本 Pod 日志记录

    您好 我正在尝试设置基本日志记录以将所有 Pod 日志放在一个位置 以下是我创建的 pod spec 但在上述位置找不到日志的踪迹 下面的模板中可能缺少什么 apiVersion v1 kind Pod metadata name coun
  • 将数据从一张纸复制到另一张纸的APP脚本

    我尝试使用此脚本将数据从一张工作表复制到另一张工作表 但是当我更新源工作表中的数据并运行脚本时 整个数据都会被复制 我只想将更新的数据复制到目标工作表而不重叠 谁能建议该怎么做 function copyPaste var ss Sprea
  • Windows 10 conda 未被识别为内部或外部命令

    试着 conda install c conda forge requests futures 0 9 7 但失败了 conda is not recognized as an internal or external command C
  • REST api 可以通过两个 HTTP 方法公开吗?

    问题是我们有一个复杂的搜索 api 查询字符串 并且希望让用户可以方便地使用 body 所以我们希望同时允许 GET 和 POST 或 PUT 我知道 对于搜索是否为只读操作存在争论 并且根据 REST 标准 它应该只能是 GET 据我了解
  • 将 ObjectId 字段正确映射到字符串

    我正在对 RDBMS 世界进行一些探索 进入 MongoDB 的神秘海洋 我正在使用 Spring Data 来帮助我进行冒险 我需要在两个集合中的文档之间创建手动引用 我读到 DBRef 很昂贵 我的 pojo 是这样的 public c
  • 皮纳克斯还活着吗?

    我见过Pinax http pinaxproject com 过去我想用它 今天我想用它 它的版本是0 7 我想知道它是否仍在开发中 它非常有活力 正如你可以看到的GitHub 存储库 http github com pinax pinax
  • 为什么 Azure IoT 中心中有主键和辅助键?

    在 Azure IoT 中心创建共享访问策略或注册设备时 将生成主密钥和辅助密钥对 我注意到我可以使用主键或辅助键将设备连接到 IoT 中心 那么 拥有主键 辅助键的目的是什么 我应该如何设计这两个键的使用 主键和辅助键的目标有两个 首先
  • Maven/Junit 并行执行 - Cucumber-JVM v4.0.0

    我正在努力获取与 JUnit Maven 一起使用的 Cucumber JVM v4 0 0 的新并行执行功能 作为指定here https github com cucumber cucumber jvm tree v4 0 0 juni