Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arquillian and Cobertura: 0% percent coverage or ClassNotFoundException #25

Open
gerrit-hohl opened this issue Dec 19, 2016 · 4 comments

Comments

@gerrit-hohl
Copy link

Hello everyone, 馃槃

I have a working Arquillian based WildFly test within a Maven build. And now I want to add Cobertura coverage tests.

But it seems it isn't easy: If I just include Cobertura through the Cobertura Maven plugin my build fails because every class has a coverage of 0%, the tests are marked as "Error" (only during the Cobertura test execution, the normal test execution works without any problems) and I get the following error in the console:

java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector from [Module "deployment.91f93bde-a5de-4cd1-a8e4-d1174885713f.war:main" from Service Module Loader]

And if I add the Cobertura library to the deployment, I get the following error at the end of the complete testing:

Exception in thread "Thread-94" java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/ClassData
    at net.sourceforge.cobertura.coveragedata.ProjectData.getOrCreateClassData(ProjectData.java:88)
    at net.sourceforge.cobertura.coveragedata.TouchCollector.applyTouchesOnProjectData(TouchCollector.java:109)
    at net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(ProjectData.java:272)
    at net.sourceforge.cobertura.coveragedata.SaveTimer.run(SaveTimer.java:33)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.ClassData from [Module "deployment.10d71cf1-6f23-46b2-9295-dd93eb249f3f.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    ... 5 more

Then I get a coverage rate. But it is very ugly and the next colleague stumbling across this message will try to fix it.

Is there a way to fix that problem?
I guess it's about the different class loaders and that the inner Cobertura library tries to communicate with the outer Cobertura library. But I have no clue how to solve something like that.

P.S.: I posted a similar request as a thread in the Arquillian forum. I also opened an issue in the Cobertura project.

@Jroosterman
Copy link

What version of Cobertura and Arquillian are you using.

@mamghari
Copy link

mamghari commented Jan 2, 2017

Hi everyone,

I have exactly the same issue with the version 2.7 of the maven plugin, on Java 8/Jenkins environment.

Do you have any idea why this issue happens ?

Thank you.

@mamghari
Copy link

mamghari commented Jan 2, 2017

I found a workaround that could be integrated into the maven plugin, I think the asm dependency should be updgraded to 5.1 in the next release.

In my pom.xml file I changed the asm version dependency from the plugin management section like following:

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>cobertura-maven-plugin</artifactId>
					<version>${cobertura.version}</version>
					<dependencies>  
		                                <dependency>  
		                                          <groupId>org.ow2.asm</groupId>  
		                                         <artifactId>asm</artifactId>  
		                                         <version>5.1</version>  
		                                </dependency>  
	            	                </dependencies>  
					<configuration>
						......
					</configuration>
					<executions>
						.....
					</executions>
				</plugin>

inpsired from http://www.befreeman.com/2014/09/getting-cobertura-code-coverage-with.html

@mmarquezvacas
Copy link

I'm having the same problem. I've made the "asm" plugin workaround (version 5.1) and cobertura plugin (version 2.7) doesn't recognize Arquillian tests. I get the following error: "failed coverage check. Branch coverage rate of 0.0% is below 75.0%", in all my test classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants