I recently had this very annoying problem come out of nowhere. Running my unit tests with EclEmma coverage enabled causes the following dialog window to pop up from Eclipse:
For the search engines, it reads:
No coverage data has been collected during this coverage Session.
Please do not terminate the Java process manually from Eclipse.
No coverage information is provided for any of the classes in my project.
Needless to say I am not terminating the Java process manually. To try and fix it I: reimported my project, upgraded Java, reinstalled Emma, restarted my Macbook Pro, made sure that temp filesystem space looked good, and 20 other things I'm forgetting right now.
I finally noticed that it was only a couple of my open source projects generating this error and decided to whittle down one of my tests. Here's the minimum test that reproduces the problem.
Test class I'm trying to get coverage on:
public class Foo {
public void method() {
System.out.println("hello");
}
}
Here's the junit class which drives it:
public class EclEmmaFailureTest {
@Test(timeout = 100000) // if you remove the timeout it works
public void testStuff() {
// this should cover Foo 100%
new Foo().method();
// if you comment this out stuff works
org.apache.commons.logging.LogFactory.getLog(getClass());
}
}
The commons-log Log
reference in the test seems to break the coverage collection. I've posted a working repo at: https://github.com/j256/eclemma-failure
If you do any of the following, the problem goes away:
- Comment out the
LogFactory.getLog(getClass())
call.
- Remove the junit
@Test
timeout field.
- Downgrade Junit from 4.13.1 to 4.12.
I'm running Emma version 3.1.3 and my test program depends on commons-logging version 1.2.
I have a downgrade path that resolves this problem and gets me working again but Junit 4.12 has security issues. I'm curious if someone knows of the specific issue with junit or emma that is causing this.
Jacoco is also affected which isn't surprising. Here's my coverage report before upgrading to Junit 4.13.1 showing 80% coverage and here it is afterwards with no coverage information available showing 0%.
Thanks.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…