调试器无法与 JMockit 一起使用
希望这里对某人来说是一个简单的问题......
我正在使用 RAD 7.5.2,并且正在编写 Junit 测试。 我用 JUnit 3 很好地编写了它们,然后我想模拟一些函数调用。 所以我加载了 jmockit 0.9.7 和 Junit 4.6。 我还包括 -javaagent:jmockit.jar 作为 VM 参数。
当我“Run As Junit Test”时,它完全没有问题(至少我在输出中看不到任何问题)。 Junit 的输出良好,并且没有错误转储到控制台。
当我“调试为 Junit 测试”时,它不起作用。 它把我转入:
InstrumentationImpl.class --> 未找到源
...当我点击继续时...
NativeMethodAccessorImpl.class --> 未找到源
...当我点击继续...
JUnit 在此之后结束。 它将以下内容转储到控制台:
Exception in thread "main" java.lang.reflect.InitationTargetException 在 sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:618) 在sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:160) 引起:java.lang.UnsatisfiedLinkError:sun/instrument/InstrumentationImpl.redefineClasses0([Ljava/lang/instrument/ClassDefinition;)V 在sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:98) 在mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:197) 在mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:184) 在mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:116) 在mockit.internal.RedefinitionEngine.setUpInternalStartupMock(RedefinitionEngine.java:53) 在mockit.internal.Startup.loadInternalStartupMocks(Startup.java:123) 在mockit.internal.Startup.initialize(Startup.java:110) 在mockit.internal.Startup.premain(Startup.java:97) ... 5 个以上
致命错误:-javaagent 的处理失败
我可以在测试中毫无问题地运行 JUnit 3 和 JUnit 4,这是当我使用 -javaagent:jmockit.jar (与调试器一起使用时;它们本身是好吧)事情变得很难看,我必须这样做才能使用 jmockit 的东西。
想法?
Hopefully an easy question here for someone.....
I'm using RAD 7.5.2, and am writing Junit tests. I was writing them just fine with JUnit 3, and then I wanted to mock up some function calls. So I loaded up jmockit 0.9.7 and Junit 4.6. I also include -javaagent:jmockit.jar as a VM argument.
When I "Run As Junit Test", it goes along with no problems at all (at least, none that I can see on the output). The output of Junit is good, and no errors are dumped to the console.
When I "Debug as Junit Test", it won't work. It dumps me out into:
InstrumentationImpl.class --> Source not found
...and when I hit continue....
NativeMethodAccessorImpl.class --> Source not found
...and when I hit continue...
The JUnit ends after this. It dumps the following to the console:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:618)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:160)
Caused by: java.lang.UnsatisfiedLinkError: sun/instrument/InstrumentationImpl.redefineClasses0([Ljava/lang/instrument/ClassDefinition;)V
at sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:98)
at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:197)
at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:184)
at mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:116)
at mockit.internal.RedefinitionEngine.setUpInternalStartupMock(RedefinitionEngine.java:53)
at mockit.internal.Startup.loadInternalStartupMocks(Startup.java:123)
at mockit.internal.Startup.initialize(Startup.java:110)
at mockit.internal.Startup.premain(Startup.java:97)
... 5 more
Fatal error: processing of -javaagent failed
I can run both JUnit 3 and JUnit 4 on my tests with no problem, it's when I use the -javaagent:jmockit.jar (with the debugger; by themselves they're fine) that things get ugly, and I have to do that to use the jmockit stuff.
Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常在调试模式下运行使用 JMockit(带或不带“-javaagent”JVM 参数)的 JUnit 测试,并且从未遇到过任何问题。
您确定“调试为 Junit 测试”配置的类路径与“运行为 Junit 测试”配置的类路径相同吗? 由于您收到 UnsatisfiedLinkError,可能是缺少一些 jar 文件。
如果这不是错误的原因,那么可能是 RAD 7.5.2 特有的原因...
I regularly run JUnit tests that use JMockit (with and without the "-javaagent" JVM argument) in debug mode, and never had any issues.
Are you sure the classpath for the "Debug as Junit Test" configuration is identical to the one for "Run As Junit Test"? Since you got an UnsatisfiedLinkError, it may be that there is some jar file missing.
If that is not the cause of the error, then maybe it is something specific to RAD 7.5.2...