Code: added test coverage reports by JaCoCo lib (generate by command like "mvn install -Djacoco.skip=false");

Code: added test coverage support for Sonar reports;
This commit is contained in:
Oleg Agafonov 2021-08-27 20:51:27 +04:00
parent 389a019b3b
commit d481172eb4
4 changed files with 53 additions and 6 deletions

1
.gitignore vendored
View file

@ -15,6 +15,7 @@ Mage.Client/target
Mage.Common/target Mage.Common/target
# Mage.Plugins # Mage.Plugins
Mage.Plugins/target
Mage.Plugins/Mage.Card.Plugin/target Mage.Plugins/Mage.Card.Plugin/target
Mage.Plugins/Mage.Counter.Plugin/target Mage.Plugins/Mage.Counter.Plugin/target
Mage.Plugins/Mage.Theme.Plugin/target Mage.Plugins/Mage.Theme.Plugin/target

View file

@ -81,9 +81,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View file

@ -64,9 +64,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

52
pom.xml
View file

@ -51,16 +51,52 @@
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<!-- JaCoCo Code Coverage report generation -->
<!-- Examples: http://tdongsi.github.io/blog/2017/09/23/jacoco-in-maven-project/ -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<!-- prepare command line to inject in java agent (collect code executing stats) -->
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<!-- generate current module's report -->
<id>generate-code-coverage-report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<!-- generate combined report (current and dependency modules) -->
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
<!--
for compatible with jacoco code coverage - argLine moved to properties section
<configuration> <configuration>
<argLine>-Dfile.encoding=UTF-8</argLine> <argLine>-Dfile.encoding=UTF-8</argLine>
</configuration> </configuration>
-->
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
@ -99,8 +135,24 @@
<properties> <properties>
<mage-version>1.4.49</mage-version> <mage-version>1.4.49</mage-version>
<argLine>-Dfile.encoding=UTF-8</argLine>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format> <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
<!--
JaCoCo code coverage disabled by default. If you need to generate
execute stats and reports then run tests by maven command
like "mvn install -Djacoco.skip=false".
Stats:
- load coverage data for IntelliJ IDEA from ./target/jacoco.exec
- web report in ./target/site/jacoco/index.html
- for sonar support see below
-->
<jacoco.skip>true</jacoco.skip>
<!-- Sonar settings for code coverage. Must be only one report for all modules (use report-aggregate goal report from JaCoCo) -->
<aggregate.report.dir>Mage.Verify/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
<sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
</properties> </properties>
<dependencyManagement> <dependencyManagement>