jmhofer / eCobertura

This is just a mirror of the bitbucket repo!
http://ecobertura.johoop.de
Eclipse Public License 1.0
17 stars 6 forks source link

Classpath issue with multiple projects #3

Closed philipa closed 14 years ago

philipa commented 14 years ago
  1. Create a Java project, "Test1" containing a class foo.Bah.
  2. Create another project, "Test2" containing a unit test foo.TestBah that uses the class foo.Bah.
  3. Select the unit test and choose "Cover as Unit Test".

The result is the following in a console window:

Class not found foo.TestBah
java.lang.ClassNotFoundException: foo.TestBah
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
jmhofer commented 14 years ago

Thanks for the detailed issue description. - I'll look into it.

jmhofer commented 14 years ago

I think I've fixed this issue, too, now, for the next release 0.9.6. - At least, I can't reproduce the exception, and I get coverage data from the launches.

philipa commented 14 years ago

Thanks, I'll give this a spin when 0.9.6 is out.

mic- commented 14 years ago

I'm still having this issue with 0.9.6.

I've got multiple projects in the same workspace - all with their own set of packages and tests. Something like this:

If I pick "Cover As.." -> "JUnit Test" on FooTest.java I get a "Class not found rev.domain.name.b.FooTest" error, and all the code in Foo.java is highlighted red as untested. The same things happens no matter which of my classes I try to cover. (By "the same thing" I don't mean that it complains about not being able to find FooTest all the time, but that it can't find whatever class I'm trying to cover.)

All the projects were created by importing them in Eclipse through Maven. We've also got Cobertura running on a Hudson build server, which works fine. But it would certainly be nice to be able to do coverage checks locally before checking in new tests on the build server.

jmhofer commented 14 years ago

That's strange. I'll have to look into that some more. I'll try to recreate your project structure from above and see what happens... - maybe you want to send me your project's relevant ".classpath"?

jflowers commented 14 years ago

I have the same issue as mic. IF there is anything I can do to help please let me know. Is there any way to follow this issue (i.e. get notified when it is resolved)?

jmhofer commented 14 years ago

Please send me your project's relevant ".classpath" if possible. - Also, can you tell me whether your project's output directory contains anything other than ".class" files? I think I may have a bug related to that in the current plugin version.

mic- commented 14 years ago

.classpath:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src"/>
<classpathentry kind="src" output="target/test-classes" path="test/junit"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/android-classes"/>
</classpath>

The 'target' directory contains the subdirectories 'android-classes' (which is empty), 'classes' (which contains '.class' files), 'maven-archiver' (which contains 'pom.properties') and 'test-classes' (which contains '.class' and '.java' files).

jmhofer commented 14 years ago

Alright, thanks! - Now I think that I might be able to create a similar situation and hopefully reproduce that problem.

jmhofer commented 14 years ago

I still can't reproduce this. :(

Maybe it's related to another bug with spaces in your Eclipse workspace directory? - Has your workspace directory spaces in its path?

jflowers commented 14 years ago

Nope :-(

Metadata: C:\Projects\Chapter33\Trunk\Product.metadata

Projects: C:\Projects\Chapter33\Trunk\Product\Production\LetterGeneration C:\Projects\Chapter33\Trunk\Product\Production\PDPEngine C:\Projects\Chapter33\Trunk\Product\Production\VAWebServiceClient C:\Projects\Chapter33\Trunk\Product\Production\WEAMSBackEnd C:\Projects\Chapter33\Trunk\Product\Production\Wizard C:\Projects\Chapter33\Trunk\Product\Production\Chapter33Backend C:\Projects\Chapter33\Trunk\Product\Production\Chapter33CommonModels C:\Projects\Chapter33\Trunk\Product\Production\Chapter33CommonUtils C:\Projects\Chapter33\Trunk\Product\Production\Chapter33Ear C:\Projects\Chapter33\Trunk\Product\Production\Chapter33RulesBOMHelper C:\Projects\Chapter33\Trunk\Product\Production\Chapter33RuleService C:\Projects\Chapter33\Trunk\Product\Production\Chapter33RulesXOM C:\Projects\Chapter33\Trunk\Product\Production\Chapter33Security C:\Projects\Chapter33\Trunk\Product\Production\Chapter33Web

jmhofer commented 14 years ago

Please try with the 0.9.7 I released today. - I have a little bit of hope that it's due to non-class files in the classpath, where I fixed another bug.

jmhofer commented 14 years ago

... and if someone could export some dummy project that produces this exception and send it to me, so that I can try and import it into my workspace and perhaps reproduce the issue like this, please do so!

phdoerfler commented 14 years ago

I got the same issue with my project, too. At least the stacktrace looks the same (despite the line numbers). The run config is checked in at the project's root directory and runs the tests via specs' JUnit runner. There are no other build tools - despite sbt - involved. Whilst the project is the only active one in the workspace, there are other ones hanging around, too.

Hope this helps ;)

jmhofer commented 14 years ago

Finally found it thanks to crumb... you can work around this issue by putting all classes into the same output folder. eCobertura doesn't currently work with multiple output folders. Will fix this asap.

jmhofer commented 14 years ago

Should now really be fixed in 0.9.8. Please check the new release.

phdoerfler commented 14 years ago

works for me ;)

jmhofer commented 14 years ago

Closing this as the last feedback was positive and I'm fairly sure I fixed exactly this problem now.

jflowers commented 14 years ago

thanks for the fix!!! you rock :-)

mic- commented 14 years ago

I've been assigned to a new project, so I don't have access to the project where this was an issue any longer, and thus can't verify that the issue has been solved. If I get back to it at some later point I'll try out the latest eCobertura version.