Problem
Tests that run with PowerMock are not reporting coverage
Solution
Due to an issue with PowerMock till version 1.7.1, tests would fail when using the SeaLights agent.
Therefore, by default, the SeaLights agent ignores all classes loaded with the PowerMock class loader and therfore coverage will not be received for these classes.
If you want to capture coverage for classes run with PowerMock, you need to first upgrade to at lease version 1.7.1 of PowerMock.
Then you can remove the SeaLights restriction of PowerMock by passing the Jvm param sl.classLoadersExcluded=none
Doing so depending on your setup:
Jenkins Maven build step:
Under 'Invoke top-level Maven targets with SeaLights Continuous Testing'->SeaLights...->SeaLights Advanced...->'Additional Arguments' add 'sealightsJvmParams=sl.classLoadersExcluded:none'
Maven Automatic configuration
Edit your JSON file to include a new JvmParams
{ ... "sealightsJvmParams": {"sl.classLoadersExcluded":"none"}, ... }
Maven pom.xml
In the configuration section add an entry for 'classLoadersExcluded' set to none like the following:
<profile> <id>sealights</id> <build> <plugins> <plugin> <groupId>io.sealights.on-premise.agents.plugin</groupId> ... <configuration> ... <classLoadersExcluded>none</classLoadersExcluded> </configuration> <executions> ...
Gradle build.gradle
In the sealights section add a parameter called 'classLoadersExcluded' set to none like in the following:
allprojects { p -> if(project.hasProperty('sealights')){ apply plugin: 'io.sealights.on-premise.agents.plugin.sealights-gradle-plugin' sealights { ... classLoadersExcluded = "none" } }
Command line (Java CLI)
Pass the -Dsl.classLoadersExcluded=none to the JVM:
java -Dsl.classLoadersExcluded=none -jar ...
Related articles