mirror of
https://github.com/jlengrand/quarkus.git
synced 2026-03-10 08:41:22 +00:00
Initial code coverage support
This commit is contained in:
committed by
Guillaume Smet
parent
860ae3adcf
commit
8b1a42aae4
@@ -119,6 +119,15 @@ By default the build will use the native image server. This speeds up the build,
|
||||
not being invalidated correctly in some cases. To run a build with a new instance of the server you can use
|
||||
`./mvnw install -Dnative-image.new-server=true`.
|
||||
|
||||
### Test Coverage
|
||||
|
||||
Quarkus uses Jacoco to generate test coverage. If you would like to generate the report run `mvn install -Ptest-coverage`,
|
||||
then change into the `coverage-report` directory and run `mvn package`. The code coverage report will be generated in
|
||||
`target/site/jacoco/`.
|
||||
|
||||
This currently does not work on Windows as it uses a shell script to copy all the classes and files into the code coverage
|
||||
module.
|
||||
|
||||
## The small print
|
||||
|
||||
This project is an open source project, please act responsibly, be nice, polite and enjoy!
|
||||
|
||||
@@ -81,6 +81,10 @@
|
||||
<keycloak.docker.image>quay.io/keycloak/keycloak:8.0.1</keycloak.docker.image>
|
||||
|
||||
<unboundid-ldap.version>4.0.13</unboundid-ldap.version>
|
||||
|
||||
<!-- Code Coverage Properties-->
|
||||
<jacoco.agent.argLine></jacoco.agent.argLine>
|
||||
<jacoco.version>0.8.5</jacoco.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -166,6 +170,7 @@
|
||||
<systemProperties>
|
||||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||
</systemProperties>
|
||||
<argLine>${jacoco.agent.argLine}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -636,5 +641,35 @@
|
||||
</pluginManagement>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>test-coverage</id>
|
||||
<properties>
|
||||
<jacoco.agent.argLine>${jacoco.activated.agent.argLine}</jacoco.agent.argLine>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>io.quarkus*</include>
|
||||
</includes>
|
||||
<propertyName>jacoco.activated.agent.argLine</propertyName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
1
coverage-report/.gitignore
vendored
Normal file
1
coverage-report/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
src/main/java
|
||||
94
coverage-report/pom.xml
Normal file
94
coverage-report/pom.xml
Normal file
@@ -0,0 +1,94 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>quarkus-build-parent</artifactId>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<version>999-SNAPSHOT</version>
|
||||
<relativePath>../build-parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>quarkus-coverage-report</artifactId>
|
||||
<name>Quarkus Test Coverage Report</name>
|
||||
<description>Aggregates and compiles jacoco test coverage report.
|
||||
This does not currently work on Windows.
|
||||
</description>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<format.skip>true</format.skip>
|
||||
</properties>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-classes-and-source</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>prepare.sh</executable>
|
||||
<workingDirectory>${project.basedir}</workingDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>merge-reports</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>merge</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/../</directory>
|
||||
<includes>
|
||||
<include>**/target/jacoco.exec</include>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>compile-report</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<title>Quarkus</title>
|
||||
<footer>Code Coverage Report for Quarkus ${project.version}</footer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
18
coverage-report/prepare.sh
Executable file
18
coverage-report/prepare.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
rm -r target/classes src/main/java
|
||||
mkdir -p target/classes
|
||||
mkdir -p src/main/java
|
||||
|
||||
for j in '../extensions' '../core' '../devtools' '../independent-projects/'
|
||||
do
|
||||
for i in `find $j -regex .*target/classes `
|
||||
do
|
||||
cp -r $i/* target/classes/
|
||||
done
|
||||
for i in `find $j -regex .*src/main/java `
|
||||
do
|
||||
cp -r $i/* src/main/java/
|
||||
done
|
||||
done
|
||||
#needed to make sure the script always suceeds
|
||||
echo "complete"
|
||||
@@ -93,7 +93,13 @@ public class BootstrapMavenOptions {
|
||||
|
||||
public String[] getOptionValues(String name) {
|
||||
final Object o = options.get(name);
|
||||
return o == null ? null : o instanceof String ? new String[] { o.toString() } : (String[]) o;
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
if (o instanceof String[]) {
|
||||
return (String[]) o;
|
||||
}
|
||||
return new String[] { o.toString() };
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
Reference in New Issue
Block a user