Created
May 22, 2022 07:25
-
-
Save muhdkhokhar/d5f50deadaff06f425d7feba34629316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<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> | |
<groupId>tutorial</groupId> | |
<artifactId>powermock-jacoco-coverage</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<!--Jacoco version--> | |
<jacoco.version>0.7.4.201502262128</jacoco.version> | |
<!--Sonar coverage related properties--> | |
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> | |
<sonar.jacoco.reportPath>${project.basedir}/target/jacoco-ut.exec</sonar.jacoco.reportPath> | |
<sonar.jacoco.itReportPath>${project.basedir}/target/jacoco-it.exec</sonar.jacoco.itReportPath> | |
<junit.version>4.12</junit.version> | |
<powermock.version>1.7.0</powermock.version> | |
<jdk.version>1.8</jdk.version> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version> | |
<maven-failsafe-plugin.version>2.12.4</maven-failsafe-plugin.version> | |
</properties> | |
<dependencies> | |
<!--Junit as test--> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>${junit.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<!--powermock API for Mockito--> | |
<dependency> | |
<groupId>org.powermock</groupId> | |
<artifactId>powermock-api-mockito</artifactId> | |
<version>${powermock.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.powermock</groupId> | |
<artifactId>powermock-core</artifactId> | |
<version>${powermock.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>org.powermock</groupId> | |
<artifactId>powermock-module-junit4</artifactId> | |
<version>${powermock.version}</version> | |
</dependency> | |
<!--Jacoco required at runtime to build offline coverages--> | |
<dependency> | |
<groupId>org.jacoco</groupId> | |
<artifactId>org.jacoco.agent</artifactId> | |
<version>${jacoco.version}</version> | |
<classifier>runtime</classifier> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<configuration> | |
<source>${jdk.version}</source> | |
<target>${jdk.version}</target> | |
<encoding>${project.build.sourceEncoding}</encoding> | |
</configuration> | |
</plugin> | |
<!--Jacoco offline instrument to work with powermock--> | |
<plugin> | |
<groupId>org.jacoco</groupId> | |
<artifactId>jacoco-maven-plugin</artifactId> | |
<version>${jacoco.version}</version> | |
<executions> | |
<!--Performs offline instrumentation.--> | |
<execution> | |
<id>default-instrument</id> | |
<goals> | |
<goal>instrument</goal> | |
</goals> | |
</execution> | |
<!--Restores original classes as they were before offline instrumentation.--> | |
<execution> | |
<id>default-restore-instrumented-classes</id> | |
<goals> | |
<goal>restore-instrumented-classes</goal> | |
</goals> | |
</execution> | |
<!--Now for integration tests--> | |
<!--Same as prepare-agent, but provides default values suitable for integration-tests:--> | |
<execution> | |
<id>prepare-it-agent</id> | |
<phase>package</phase> | |
<goals> | |
<goal>prepare-agent-integration</goal> | |
</goals> | |
<configuration> | |
<!--The path variable should not change.This is used by Sonar--> | |
<destFile>${sonar.jacoco.itReportPath}</destFile> | |
<append>true</append> | |
</configuration> | |
</execution> | |
<execution> | |
<id>report</id> | |
<phase>prepare-package</phase> | |
<goals> | |
<goal>report</goal> | |
</goals> | |
<configuration> | |
<dataFile>${sonar.jacoco.reportPath}</dataFile> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!--END of jacoco plugin settings--> | |
<!--*** Maven surefire plugin to generate coverage file ***--> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>${maven-surefire-plugin.version}</version> | |
<configuration> | |
<!--Exclude any Integration Test--> | |
<excludes> | |
<exclude>**/*Integration*Test*</exclude> | |
</excludes> | |
<!--Setup Jacoco Junit file path here--> | |
<systemPropertyVariables> | |
<jacoco-agent.destfile>${sonar.jacoco.reportPath}</jacoco-agent.destfile> | |
</systemPropertyVariables> | |
</configuration> | |
</plugin> | |
<!--Maven failsafe for Integration Test--> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-failsafe-plugin</artifactId> | |
<version>${maven-failsafe-plugin.version}</version> | |
<configuration> | |
<!--Include only integration test here--> | |
<includes> | |
<include>**/*IntegrationTest*</include> | |
</includes> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> | |
<goal>integration-test</goal> | |
<goal>verify</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment