FELIX-3989 Add support for determining code coverage with integration testcases
Adding config for JoCoCo maven plugin to capture code coverage report. Following command would enable coverage
mvn clean install -Pide,felix,coverage
For now the coverage is bit low hence not enabling the check by default.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1459658 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jaas/pom.xml b/jaas/pom.xml
index c49e867..7dca5d1 100644
--- a/jaas/pom.xml
+++ b/jaas/pom.xml
@@ -164,7 +164,8 @@
<systemPropertyVariables>
<project.bundle.file>${bundle.file.name}</project.bundle.file>
<project.boot.file>${bundle.file.name}</project.boot.file>
- </systemPropertyVariables>
+ <coverage.command>${coverage.command}</coverage.command>
+= </systemPropertyVariables>
</configuration>
</plugin>
<plugin>
@@ -301,6 +302,58 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>coverage</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jacoco</groupId>
+ <artifactId>jacoco-maven-plugin</artifactId>
+ <version>0.6.2.201302030002</version>
+ <executions>
+ <execution>
+ <id>prepare-agent</id>
+ <goals>
+ <goal>prepare-agent</goal>
+ </goals>
+ <configuration>
+ <propertyName>coverage.command</propertyName>
+ <includes>
+ <include>org.apache.felix.jaas.*</include>
+ </includes>
+ <excludes>
+ <exclude>org.apache.felix.jaas.integration.*</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>report</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>report</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>check</id>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ <configuration>
+ <check>
+ <classRatio>100</classRatio>
+ <instructionRatio>90</instructionRatio>
+ <methodRatio>95</methodRatio>
+ <branchRatio>85</branchRatio>
+ <complexityRatio>85</complexityRatio>
+ <lineRatio>90</lineRatio>
+ </check>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>felix</id>
diff --git a/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java b/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java
index f74431a..72da9aa 100644
--- a/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java
+++ b/jaas/src/test/java/org/apache/felix/jaas/integration/JaasTestBase.java
@@ -61,6 +61,10 @@
// the name of the system property providing the bundle file to be installed and tested
protected static final String BUNDLE_JAR_SYS_PROP = "project.bundle.file";
+ // the name of the system property which captures the jococo coverage agent command
+ //if specified then agent would be specified otherwise ignored
+ protected static final String COVERAGE_COMMAND = "coverage.command";
+
// the default bundle jar file name
protected static final String BUNDLE_JAR_DEFAULT = "target/jaas.jar";
@@ -98,11 +102,21 @@
streamBundle(createCommonTestUtilBundle()),
+ addCodeCoverageOption(),
addExtraOptions());
final Option vmOption = (paxRunnerVmOption != null) ? CoreOptions.vmOption(paxRunnerVmOption) : null;
return OptionUtils.combine(base, vmOption);
}
+ private Option addCodeCoverageOption()
+ {
+ String coverageCommand = System.getProperty(COVERAGE_COMMAND);
+ if(coverageCommand != null){
+ return CoreOptions.vmOption(coverageCommand);
+ }
+ return null;
+ }
+
@ProbeBuilder
public TestProbeBuilder extendProbe(TestProbeBuilder builder)
{