SLING-9702 Enable code coverage with JaCoCo
inherit system properties from parent and check command
diff --git a/pom.xml b/pom.xml
index 58ccef5..093d6bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,41 +64,12 @@
</executions>
<configuration>
<redirectTestOutputToFile>true</redirectTestOutputToFile>
- <systemProperties>
- <property>
- <name>bundle.filename</name>
- <value>${basedir}/target/${project.build.finalName}.jar</value>
- </property>
- <property>
- <name>jacoco.command</name>
- <value>${jacoco.command}</value>
- </property>
- </systemProperties>
+ <systemPropertyVariables combine.children="append">
+ <bundle.filename>${basedir}/target/${project.build.finalName}.jar</bundle.filename>
+ </systemPropertyVariables>
</configuration>
</plugin>
<plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <configuration>
- <propertyName>jacoco.command</propertyName>
- </configuration>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- <execution>
- <id>report</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>report</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
</plugin>
diff --git a/src/test/java/org/apache/sling/scripting/groovy/it/GroovyTestSupport.java b/src/test/java/org/apache/sling/scripting/groovy/it/GroovyTestSupport.java
index ba2e338..19cdbac 100644
--- a/src/test/java/org/apache/sling/scripting/groovy/it/GroovyTestSupport.java
+++ b/src/test/java/org/apache/sling/scripting/groovy/it/GroovyTestSupport.java
@@ -18,6 +18,8 @@
*/
package org.apache.sling.scripting.groovy.it;
+import java.util.Objects;
+
import javax.inject.Inject;
import javax.script.ScriptEngineFactory;
@@ -32,6 +34,8 @@
import org.ops4j.pax.exam.ProbeBuilder;
import org.ops4j.pax.exam.TestProbeBuilder;
import org.ops4j.pax.exam.options.ModifiableCompositeOption;
+import org.ops4j.pax.exam.options.OptionalCompositeOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
import org.ops4j.pax.exam.util.Filter;
import org.osgi.service.http.HttpService;
@@ -43,6 +47,7 @@
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.when;
public class GroovyTestSupport extends TestSupport {
@@ -84,10 +89,17 @@
mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
junitBundles(),
- vmOption(System.getProperty("jacoco.command"))
+ jacoco() // remove with Testing PaxExam 4.0
);
}
+ // remove with Testing PaxExam 4.0
+ protected OptionalCompositeOption jacoco() {
+ final String jacocoCommand = System.getProperty("jacoco.command");
+ final VMOption option = Objects.nonNull(jacocoCommand) && !jacocoCommand.trim().isEmpty() ? vmOption(jacocoCommand) : null;
+ return when(Objects.nonNull(option)).useOptions(option);
+ }
+
@ProbeBuilder
public TestProbeBuilder probeConfiguration(final TestProbeBuilder testProbeBuilder) {
testProbeBuilder.setHeader(Constants.EXPORT_PACKAGE, "org.apache.sling.scripting.groovy.it.app");