并行测试期间 maven-failsafe-plugin 出错 运行
Error in maven-failsafe-plugin during parallel tests running
我有一个可用的应用程序,它 运行 的集成测试没有任何问题。
我想运行并行添加
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
到 pom 文件中的 maven-failsafe-plugin 部分。
因此本部分看起来像这样
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/IntegrationTestSuite.java</include>
</includes>
<excludes>
<exclude>**/*Tests.java</exclude>
<exclude>**/*Test.java</exclude>
</excludes>
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</execution>
</executions>
</plugin>
它 运行s 测试但是在 运行ning 结束时我收到错误
Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:integration-test (default) on project pr: Execution default of goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:integration-test failed: There was an error in the forked process org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException
at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:213)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:109)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:78)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:144)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.NullPointerException at org.apache.maven.surefire.junitcore.ConcurrentRunListener.testStarting(ConcurrentRunListener.java:129)
at org.apache.maven.surefire.common.junit4.JUnit4RunListener.testStarted(JUnit4RunListener.java:91)
at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49)
at org.junit.runner.notification.RunNotifier.notifyListener(RunNotifier.java:121)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:118)
at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.beforeStory(JUnitScenarioReporter.java:100)
at org.jbehave.core.reporters.DelegatingStoryReporter.beforeStory(DelegatingStoryReporter.java:72)
at org.jbehave.core.reporters.ConcurrentStoryReporter.beforeStory(ConcurrentStoryReporter.java:117)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:790)
at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:422)
at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:393)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:292)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
这里可能有什么问题?
好吧,我不确定这是否可行。
但如果在某些测试场景描述中有括号,则 JUnit 似乎会失败。看看this issue.
因此,请尝试从您的测试描述中删除所有括号“()”,然后再次 运行。同样,我不确定这是否可行。希望对你有帮助。
最后的解决方案是这样的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<CPU_NUMBER_MULTIPLIER_FOR_NUMBER_OF_THREADS_IN_TEST_SUITE_RUNNER>1
</CPU_NUMBER_MULTIPLIER_FOR_NUMBER_OF_THREADS_IN_TEST_SUITE_RUNNER>
</systemPropertyVariables>
<includes>
<include>**/IntegrationTestSuite.java</include>
</includes>
<excludes>
<exclude>**/*Tests.java</exclude>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
连同来自 here
的自定义跑步者
我有一个可用的应用程序,它 运行 的集成测试没有任何问题。 我想运行并行添加
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
到 pom 文件中的 maven-failsafe-plugin 部分。
因此本部分看起来像这样
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/IntegrationTestSuite.java</include>
</includes>
<excludes>
<exclude>**/*Tests.java</exclude>
<exclude>**/*Test.java</exclude>
</excludes>
<parallel>classes</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</execution>
</executions>
</plugin>
它 运行s 测试但是在 运行ning 结束时我收到错误
Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:integration-test (default) on project pr: Execution default of goal org.apache.maven.plugins:maven-failsafe-plugin:2.18.1:integration-test failed: There was an error in the forked process org.apache.maven.surefire.testset.TestSetFailedException: java.lang.NullPointerException
at org.apache.maven.surefire.common.junit4.JUnit4RunListener.rethrowAnyTestMechanismFailures(JUnit4RunListener.java:213)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:109)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:78)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:144)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: java.lang.NullPointerException at org.apache.maven.surefire.junitcore.ConcurrentRunListener.testStarting(ConcurrentRunListener.java:129)
at org.apache.maven.surefire.common.junit4.JUnit4RunListener.testStarted(JUnit4RunListener.java:91)
at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49)
at org.junit.runner.notification.RunNotifier.notifyListener(RunNotifier.java:121)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:72)
at org.junit.runner.notification.RunNotifier.fireTestStarted(RunNotifier.java:118)
at de.codecentric.jbehave.junit.monitoring.JUnitScenarioReporter.beforeStory(JUnitScenarioReporter.java:100)
at org.jbehave.core.reporters.DelegatingStoryReporter.beforeStory(DelegatingStoryReporter.java:72)
at org.jbehave.core.reporters.ConcurrentStoryReporter.beforeStory(ConcurrentStoryReporter.java:117)
at org.jbehave.core.embedder.PerformableTree$PerformableStory.perform(PerformableTree.java:790)
at org.jbehave.core.embedder.PerformableTree.performCancellable(PerformableTree.java:422)
at org.jbehave.core.embedder.PerformableTree.perform(PerformableTree.java:393)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:292)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:266)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
这里可能有什么问题?
好吧,我不确定这是否可行。
但如果在某些测试场景描述中有括号,则 JUnit 似乎会失败。看看this issue.
因此,请尝试从您的测试描述中删除所有括号“()”,然后再次 运行。同样,我不确定这是否可行。希望对你有帮助。
最后的解决方案是这样的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<CPU_NUMBER_MULTIPLIER_FOR_NUMBER_OF_THREADS_IN_TEST_SUITE_RUNNER>1
</CPU_NUMBER_MULTIPLIER_FOR_NUMBER_OF_THREADS_IN_TEST_SUITE_RUNNER>
</systemPropertyVariables>
<includes>
<include>**/IntegrationTestSuite.java</include>
</includes>
<excludes>
<exclude>**/*Tests.java</exclude>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
连同来自 here
的自定义跑步者