ClassFormatError using JMockit with EMMA

I am trying to use EMMA to measure the coverage of some JUnit tests that use JMockit. But when I try to run JMockit tests after using EMMA, about a quarter of the tests fail with the following error:

com.logstorage.engine.sensor.SensorManagerTest.setUpBeforeClass(SensorManagerTest.java:98)
    java.lang.ClassFormatError
    at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
    at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:150)
    at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:152)
    at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:139)
    at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:73)
    at mockit.Mockit.setUpMock(Mockit.java:235)
    at com.myapp.MyTest.setUpBeforeClass(MyTest.java:98)

I do not see any pattern as to which tests fail and which do not. I think this is just a bug in JMockit, but does anyone know of a workaround?

I found a very similar question called "Getting ClassFormatError with EMMA?" but the solution does not work for me (I do not use any reentrant = true mock methods). Any other ideas?

Thanks in advance.

+3
source share
4 answers

- , , , , - .

ant, , vars javac target debuglevel. .

<javac srcdir="${src}" destdir="${bin}" debug="on" debuglevel="lines,source,vars" nowarn="true" /> 

:

<javac srcdir="${src}" destdir="${bin}" debug="on" debuglevel="lines,source" nowarn="true">

, , JMockit - annyoing, .

+2

, , , ClassFormatError EMMA, JMockit.

, JMockit Coverage? jmockit-coverage.jar classpath , . , ( - ) HTML "-" . !

0

. jMockit TeamCity EMMA . :

, :

@After
public void tearDown() throws Exception {
  Mockit.tearDownMocks(ClassWithStaticMethods.class);
}
0

jmockit 1.5 .

0

Source: https://habr.com/ru/post/1709002/


All Articles