首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >黄瓜和Jacoco

黄瓜和Jacoco
EN

Stack Overflow用户
提问于 2017-07-14 08:42:41
回答 1查看 1.5K关注 0票数 0

当我在我的项目和由maven运行的测试中使用黄瓜、maven-surefire-plugin、maven-故障安全插件和jacoco时,我得到了这个错误。

有人能帮我解决这个问题吗?

代码语言:javascript
复制
org.sonar.java.jacoco.JacocoController$JacocoControllerError: Looks like several tests executed in parallel in the same JVM, thus coverage per test can't be recorded correctly.
    at org.sonar.java.jacoco.JacocoController.onTestStart(JacocoController.java:58)
    at org.sonar.java.jacoco.JUnitListener.testStarted(JUnitListener.java:42)
    at org.junit.runner.notification.SynchronizedRunListener.testStarted(SynchronizedRunListener.java:49)
    at org.junit.runner.notification.RunNotifier$3.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 org.junit.internal.runners.model.EachTestNotifier.fireTestStarted(EachTestNotifier.java:42)
    at cucumber.runtime.junit.JUnitReporter.result(JUnitReporter.java:103)
    at cucumber.runtime.Runtime.runStep(Runtime.java:310)
    at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
    at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
    at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:44)
    at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:102)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
    at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:95)
    at cucumber.api.junit.Cucumber.runChild(Cucumber.java:38)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at cucumber.api.junit.Cucumber.run(Cucumber.java:100)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
    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)

pom协议是这样的:

代码语言:javascript
复制
           <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <argLine>${jacoco.agent.ut.arg}</argLine>
                <properties>
                  <property>
                    <name>listener</name>
                    <value>org.sonar.java.jacoco.JUnitListener</value>
                  </property>
                </properties>
              </configuration>
            </plugin>
            <plugin>
              <artifactId>maven-failsafe-plugin</artifactId>
              <configuration>
                <argLine>-Xmx1024m -XX:MaxPermSize=256m ${jacoco.agent.it.arg}</argLine>
                <properties>
                  <property>
                    <name>listener</name>
                    <value>org.sonar.java.jacoco.JUnitListener</value>
                  </property>
                </properties>
                <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
              </configuration>
              <executions>
                <execution>
                  <id>integration-test</id>
                  <goals>
                    <goal>integration-test</goal>
                  </goals>
                </execution>
                <execution>
                  <id>verify</id>
                  <goals>
                    <goal>verify</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <version>0.7.6.201602180812</version>
              <executions>
                <execution>
                  <id>prepare-ut-agent</id>
                  <goals>
                    <goal>prepare-agent</goal>
                  </goals>
                  <configuration>
                    <destFile>${sonar.jacoco.reportPath}</destFile>
                    <propertyName>jacoco.agent.ut.arg</propertyName>
                    <append>true</append>
                  </configuration>
                </execution>
                <execution>
                  <id>prepare-it-agent</id>
                  <goals>
                    <goal>prepare-agent-integration</goal>
                  </goals>
                  <configuration>
                    <destFile>${sonar.jacoco.itReportPath}</destFile>
                    <propertyName>jacoco.agent.it.arg</propertyName>
                    <append>true</append>
                  </configuration>
                </execution>
              </executions>
            </plugin>
EN

回答 1

Stack Overflow用户

发布于 2018-06-14 17:10:08

在对Jacoco和Cucumber进行了一些实验之后,我在我的测试演示(mini)项目中添加了'module3'。Module3为您提供了一个具体的实现/回答您的问题。见sipmle测试演示项目

在parent.pom中,您可以找到用于测试的插件(故障安全和安全)和代码覆盖率(jacoco)。在module3中,我将黄瓜测试放在一个单独的文件夹中。通过builder插件,Cucumber测试被标记为测试。您可以将这些Cucumber测试(包括步骤、功能)移动到测试文件夹中。这样,您可以将它们从其他常规测试中分离出来。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45098504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档