我已经配置了maven-surefire-plugin和jacoco插件来生成junit代码覆盖率报告。然而,我在两个不同的场景中得到了两个不同的错误。你能看看下面的错误并帮助我吗?任何帮助都是值得赞赏的。
当我在maven-surefire-plugin配置中将forkCount保持为0(零)时,所有测试都会成功执行,但不会生成jacoco报告。它给我的消息是“由于缺少执行数据文件,跳过JaCoCo执行”。
<properties>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
<tomcat.version>8.5.4</tomcat.version>
<maven.test.skip>false</maven.test.skip>
<maven.build.timestamp.format>yy.MM</maven.build.timestamp.format>
<powermock.version>2.0.0-beta.5</powermock.version>
<!-- Sonar-JaCoCo properties -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<dependencies>
<!-- START Spring boot dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
</dependency>
<dependency>
<groupId>com.testmodule</groupId>
<artifactId>test-module-common</artifactId>
<version>1.0.6</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<!-- START JUnit Test dependencies -->
<dependency>
<groupId>com.google.code.tempus-fugit</groupId>
<artifactId>tempus-fugit</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<!-- END JUnit Test dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>javax.xml.soap-api</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>${jacoco.agent.argLine}</argLine>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<append>true</append>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<phase>initialize</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacoco.agent.argLine</propertyName>
<destFile>target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>jacoco-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.testmodule.module</mainClass>
<finalName>test-module</finalName>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Added for java 10 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>test-module</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>resources/distribution.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal> <!-- goals == mojos -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo file="version.txt">${maven.build.timestamp}.${BUILD_NUMBER}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>${maven.build.timestamp}.${BUILD_NUMBER}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
您必须在使用Java10时升级jacoco版本。您可以使用JaCoCo Version0.8.3,它似乎可以解决这个问题。
我写测试。我使用的是Cucumber 6.8.1、TestNG 7.0.0。为了并行化,我连接了maven-surefire-plugin2.22.2,但我现在没有并行测试,目前我只逐一运行所有测试。 大多数测试工作良好(大约45个测试)。但是有几个测试是有问题的,即:当运行这样的测试时,我得到错误“分叉的VM在没有正确地说再见的情况下终止了。VM崩溃或System.Exit调用?”以下是全文:
我使用的是geb spock maven,ubuntu上的surefire 2.22.0版。直到两周前,它还可以正常工作,但突然我发现forked虚拟机没有恰当地说再见就终止了。虚拟机崩溃或系统崩溃。你叫出口吗 错误。以下是我的配置: 当我点击命令时,它会抛出以下错误: 下面是我完整的pom。xml 请关注这个问题。谢啦
“分叉的虚拟机在没有正确说再见的情况下终止。虚拟机崩溃或系统调用退出?” 仅用一个分叉运行这个不会产生问题(并且一切都过去了) 有一些关于这个问题的信息,包括这个StackOverflow问题和这个bug(现在似乎已经解决了) 更新#1在使用--debug(-x)运行maven目标后添加相关的out put
问题内容: 我使用Docker和https://github.com/fabric8io/docker-maven- plugin 进行集成测试。 在Windows 10( 更新为Windows 10 1709 )上的计算机上,我的构建遇到以下错误: 现在我不知道可能出什么问题,我看不到测试有任何失败。 这个问题可能是什么原因以及如何解决? 更新 我的项目具有以下配置: 父母: 子模块: 如您所见
如标题所示:我正试图从集装箱化的詹金斯奴隶那里运行Maven自动化测试,在与此斗争了一周后,现在我已经没有想法了。它的工作原理是在AWS实例与4G的RAM,但在不受限制的(在RAM和CPU)容器,它失败与错误如下。当它运行的唯一情况是当我禁用分叉故障安全插件,但这不是一个选项前进。 我尝试了各种Java /Maven/Failsafe/Surefire选项,我可以用谷歌找到,但没有运气(如添加全局
在运行单元测试时,出现以下异常: 有什么建议吗?