我正在尝试合并所有测试的涵盖范围,包括单元测试和集成测试。我有一个多模块应用程序,正在使用Maven。 层次结构如下所示:
Project :
- ad-service (Unit + IT)
- category-service (Unit + IT)
- chat-service (Unit)
我想将所有测试覆盖范围合并为一个大覆盖范围。
cd ad-service
和运行mvn clean verify sonar:sonar etc..
的时候,我正在合并单元测试和集成测试。但是,当我尝试从Project父层次结构执行mvn clean verify sonar:sonar etc..
时,我只有一次覆盖。
我试图将它们合并到一个文件中,但仍然无法正常工作。
这是我的父母pom.xml
:
<properties>
<version.thorntail>2.3.0.Final</version.thorntail>
<version.h2>1.4.197</version.h2>
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<skip-docker-build>true</skip-docker-build>
<skip-docker-compose>false</skip-docker-compose>
<dockerHost>tcp://localhost:2375</dockerHost>
<failsafe.runOrder>alphabetical</failsafe.runOrder>
<main.basedir>${project.basedir}</main.basedir>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../target/jacoco.exec</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
这是我的child pom
之一:
<properties>
<skip-docker-build>false</skip-docker-build>
<main.basedir>${project.parent.basedir}</main.basedir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>unit-tests</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test-prepare-agent</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>false</append>
<propertyName>jacoco.it.tests</propertyName>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<address>localhost</address>
<output>tcpserver</output>
<port>10001</port>
<reset>false</reset>
<skip>${skip.dump}</skip>
</configuration>
</execution>
<execution>
<id>post-integration-test-prepare-agent</id>
<phase>post-integration-test</phase>
<goals>
<goal>dump</goal>
</goals>
<configuration>
<append>false</append>
<propertyName>jacoco.it.tests</propertyName>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<address>localhost</address>
<output>tcpserver</output>
<port>10001</port>
<reset>false</reset>
<skip>${skip.dump}</skip>
</configuration>
</execution>
<execution>
<id>merge-coverage</id>
<phase>install</phase>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-merged.exec</destFile>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.exec</include>
</includes>
</fileSet>
</fileSets>
</configuration>
</execution>
<execution>
<id>verify-report</id>
<phase>install</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-merged.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.thorntail</groupId>
<artifactId>thorntail-maven-plugin</artifactId>
<configuration>
<jvmArguments>
<jvmArgument>${jacoco.it.tests}</jvmArgument>
</jvmArguments>
<properties>
<thorntail.port.offset>20000</thorntail.port.offset>
</properties>
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
<execution>
<id>pre-integration-test-start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<jvmArguments>
<jvmArgument>${jacoco.it.tests}</jvmArgument>
</jvmArguments>
</configuration>
</execution>
<execution>
<id>verify-stop</id>
<phase>verify</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
但是之后,当我从Project /文件夹运行mvn clean verify sonar:sonar etc..
时,声纳会尝试,并且显然找不到子模块中的每个jacoco.exec报告。我尝试用-Dsonar.coverage.jacoco.reportPaths=jacoco-it.exec
指定,但它什么也没改变。
任何想法如何合并所有这些结果?谢谢!