# No Coverage with PowerMock

### Problem <a href="#problem" id="problem"></a>

Tests that run with PowerMock are not reporting coverage

### Cause <a href="#cause" id="cause"></a>

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 therefore coverage will not be received for these classes.

### Solution <a href="#solution" id="solution"></a>

If you want to capture coverage for classes run with PowerMock, you need to first upgrade to at least 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: <a href="#doing-so-depending-on-your-setup" id="doing-so-depending-on-your-setup"></a>

**Jenkins Maven build step:**

Under '*Invoke top-level Maven targets with SeaLights Continuous Testing'->SeaLights...->SeaLights Advanced...->'Additional Arguments*' add `'sealightsJvmParams=sl.classLoadersExcluded:none`'

<figure><img src="https://4057366433-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAjqTCMRYvHhDgsdPLUnc%2Fuploads%2Fjvnohgk7vYoUXGp8utoF%2Fimage%20(4).png?alt=media&#x26;token=b9650365-092a-413b-913b-807f40ebe7a1" alt=""><figcaption></figcaption></figure>

**Maven Automatic configuration**&#x20;

Edit your JSON file to include a new JvmParams

{% code overflow="wrap" lineNumbers="true" %}

```
{
  ...  
  "sealightsJvmParams": {"sl.classLoadersExcluded":"none"},
  ...
}
```

{% endcode %}

**Maven pom.xml**

In the configuration section add an entry for 'classLoadersExcluded' set to none like the following:

{% code overflow="wrap" lineNumbers="true" %}

```xml
<profile>
	<id>sealights</id>
    	<build>
        	<plugins>
            	<plugin>
                	<groupId>io.sealights.on-premise.agents.plugin</groupId>
					...
					<configuration>
						...
						<classLoadersExcluded>none</classLoadersExcluded>
					</configuration>
                    <executions>
					...
```

{% endcode %}

**Gradle build.gradle**

In the Sealights section add a parameter called 'classLoadersExcluded' set to none like in the following:

{% code overflow="wrap" lineNumbers="true" %}

```
allprojects { p ->
    if(project.hasProperty('sealights')){
        apply plugin: 'io.sealights.on-premise.agents.plugin.sealights-gradle-plugin'
        sealights {
			...
			classLoadersExcluded = "none"
	}
}
```

{% endcode %}

**Command line (Java CLI)**

Pass the `-Dsl.classLoadersExcluded=none` to the JVM:

```
java -Dsl.classLoadersExcluded=none -jar ...
```

### Related articles <a href="#related-articles" id="related-articles"></a>

* [running-tests](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/go-agent/go-agent-v1/running-tests "mention") (Go)
* [setting-up-a-windows-service](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-a-windows-service "mention") (.Net)
* [setting-up-iis-listener](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/.net-core-agent/capturing-coverage-from-the-application/ms-windows-specific-configurations/setting-up-iis-listener "mention") (.Net)
* [cloud-foundry-integration](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/python-agent/capturing-coverage-from-runtime-application/cloud-foundry-integration "mention") (Python)
* [pivotal-cloud-foundry-pcf-support](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/pivotal-cloud-foundry-pcf-support "mention") (Java)
