AttachNotSupportedException while running jMockit tests on IBM JRE

前端 未结 6 1177
北海茫月
北海茫月 2020-12-19 16:55

I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK. Has anyone faced this issue? I tried given -Dcom.ibm.tools.attach.enable=

6条回答
  •  我在风中等你
    2020-12-19 17:15

    The Attach API simply doesn't work in the IBM JDK 6.0, at least on Windows. Therefore, it's necessary to use the -javaagent:jmockit.jar parameter.

    The NullPointerException that occurs at MockClassSetup.java:59, when using -javaagent, is caused by a bug in the IBM JDK. When a type referenced in an annotation attribute (@MockClass, in this case) is not present in the classpath, the JDK should throw a TypeNotPresentException. The Oracle JDKs do so as expected, but the IBM JDK returns null instead for the attribute value.

    I just implemented a workaround for this in class MockClassSetup, which will be available in the next JMockit release, by the end of september. For now, you can avoid the problem by adding TestNG to the classpath (since the "type not found" is the org.testng.TestNG class).

提交回复
热议问题