Permalink
Browse files

Added POM showing how to split integration tests and generate code co…

  • Loading branch information...
1 parent f11ace5 commit 92d3c20d6d2b1c42b20982ea89c475c94d77044b Jakub Holy committed Feb 5, 2012
Showing with 101 additions and 0 deletions.
  1. +101 −0 snippets/split_integration_tst_and_coverage-pom.xml
@@ -0,0 +1,101 @@
+<?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/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>net.jakubholy.example</groupId>
+ <artifactId>splitting-integration-tests</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>
+ Example parent POM that configures Failsafe to run all tests ending in *IT and generates code coverage for them
+ using JaCoCo.
+ Run the pahse 'verify' with the profile 'sonar' to generate code coverage.
+ Run the phase 'site' after that to generate HTML report of the code coverage.
+ </description>
+
+ <packaging>pom</packaging>
+
+ <modules>
+ <!-- add your modules here ... -->
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- For executing & reporting ntegration tests -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <version>2.11</version>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.5.4.201111111111</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <!-- Run integration tests (*IT) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <configuration>
+ <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
+ <argLine>${jacoco.agent.argLine}</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>sonar</id>
+ <!-- Enable coverage computation via JaCoCo for Sonar's needs -->
+ <build>
+ <plugins>
+ <!--
+ Compute integration test coverage for Sonar
+ Note: REQUIRES MAVEN 3 - throws InstantiationException: java.util.List otherwise
+ Beware: Sonar doesn't run the verify phase; you should always 'mvn clean install' before running sonar
+ -->
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <configuration>
+ <propertyName>jacoco.agent.argLine</propertyName> <!-- default: argLine -->
+ <includes>
+ <include>my/root/package/**</include>
+ </includes>
+ <destFile>${project.build.directory}/jacoco-integration.exec</destFile> <!-- agent -->
+ <dataFile>${project.build.directory}/jacoco-integration.exec</dataFile> <!-- report -->
+ </configuration>
+ <executions>
+ <execution>
+ <id>agent</id>
+ <goals><goal>prepare-agent</goal></goals>
+ </execution>
+ <execution>
+ <!--
+ Generate coverage report html in target/site/jacoco/ from target/jacoco.exec
+ Exec.: mvn verify site
+ -->
+ <id>report</id>
+ <phase>site</phase>
+ <goals><goal>report</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>

0 comments on commit 92d3c20

Please sign in to comment.