I can't run testng + jmockit test cases with recent testng-eclipse release

544 views
Skip to first unread message

Macyou

unread,
Oct 19, 2010, 12:03:42 PM10/19/10
to testng-users
If I have jmockit jar in my classpath I got error may like,

Setting connection parameters:127.0.0.1:43591
init jmockit:true
Exception in thread "Attach Listener"
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:
323)
at
sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:
348)
Caused by: java.lang.IllegalArgumentException: Matching real methods
not found for the following mocks:
Object invokeMethod(reflect.Method, Object, Object[])
at
mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:
259)
at
mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:
235)
at
mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:
209)
at
mockit.internal.RedefinitionEngine.setUpStartupMock(RedefinitionEngine.java:
185)
at
mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:
181)
at
mockit.internal.startup.Startup.loadInternalStartupMocks(Startup.java:
161)
at mockit.internal.startup.Startup.initialize(Startup.java:139)
at mockit.internal.startup.Startup.agentmain(Startup.java:128)
... 6 more
Agent failed to start!
org.testng.TestNGException:
An error occurred while instantiating class
com.ali.dowjones.biz.service.order.impl.OrderServiceBoImplTest: null
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:
343)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:
89)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:107)
at
org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:
117)
at org.testng.TestRunner.initMethods(TestRunner.java:394)
at org.testng.TestRunner.init(TestRunner.java:228)
at org.testng.TestRunner.init(TestRunner.java:198)
at org.testng.TestRunner.<init>(TestRunner.java:154)
at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:
120)
at org.testng.remote.RemoteTestNG
$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:178)
at org.testng.SuiteRunner
$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:540)
at org.testng.SuiteRunner.init(SuiteRunner.java:140)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:104)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1045)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1031)
at org.testng.TestNG.runSuitesLocally(TestNG.java:877)
at org.testng.TestNG.run(TestNG.java:818)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:89)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:144)
Caused by: java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:
28)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:
331)
... 18 more
Caused by: java.lang.RuntimeException:
com.sun.tools.attach.AgentInitializationException: Agent JAR loaded
but agent failed to initialize
at
mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:
126)
at
mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:
76)
at
mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:
39)
at mockit.internal.startup.Startup.verifyInitialization(Startup.java:
251)
at org.jtester.testng.JTester.<clinit>(JTester.java:108)
... 24 more
Caused by: com.sun.tools.attach.AgentInitializationException: Agent
JAR loaded but agent failed to initialize
at
sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:
112)
at
mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:
119)
... 28 more


if I specified -javaagent:<path to jmockit jar>, I got error like
this,

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:
323)
at
sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:
338)
Caused by: java.lang.IllegalArgumentException: Matching real methods
not found for the following mocks:
Object invokeMethod(reflect.Method, Object, Object[])
at
mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:
259)
at
mockit.internal.RedefinitionEngine.modifyRealClass(RedefinitionEngine.java:
235)
at
mockit.internal.RedefinitionEngine.redefineMethods(RedefinitionEngine.java:
209)
at
mockit.internal.RedefinitionEngine.setUpStartupMock(RedefinitionEngine.java:
185)
at
mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:
181)
at
mockit.internal.startup.Startup.loadInternalStartupMocks(Startup.java:
161)
at mockit.internal.startup.Startup.initialize(Startup.java:139)
at mockit.internal.startup.Startup.premain(Startup.java:122)
... 6 more
FATAL ERROR in native method: processing of -javaagent failed

But with the old version testng-eclipse plugins I run those tests
without any problems, maybe the version number earlier than 5.14.2.7.
I can't get those old version since I all updated to the latest
release.

Any idea about this problem?

Roman Timushev

unread,
Oct 21, 2010, 4:37:43 AM10/21/10
to testng-users
I have exactly the same problem. As far as I understood, TestNG plugin
adds the latest testng.jar to classpath which is incompartible with
current version of JMockit.
I have not found a good solution yet.

Roman Timushev

unread,
Oct 21, 2010, 4:47:35 AM10/21/10
to testng-users
More exact cause of this error is that JMockit tries to stub
org.testng.internal.MethodHelper.invokeMethod(Method thisMethod,
Object instance, Object[] parameters) method that doesn't exist in
latest testng.

Cédric Beust ♔

unread,
Oct 21, 2010, 9:18:53 AM10/21/10
to testng...@googlegroups.com
So it's not really an Eclipse plug-in problem and it's actually not a TestNG problem either since JMockit was using an internal method (which was refactored recently, like all good internal methods always end up being :-)).

I'll contact the JMockit people to see what we can do.

-- 
Cédric



--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric


Ronnie and Sandy

unread,
Oct 27, 2010, 4:47:07 PM10/27/10
to testng-users
Cedric, did you contact the JMockit folks? How did it go?

Cédric Beust ♔

unread,
Oct 27, 2010, 5:58:34 PM10/27/10
to testng...@googlegroups.com
Hi Ronnie,

Yes, I'm in the middle of exchanging emails with Rogerio and we're trying to come up with better ways to integrate TestNG and JMockit. I have nothing concrete to report right now.

-- 
Cédric


On Wed, Oct 27, 2010 at 1:47 PM, Ronnie and Sandy <ronniea...@gmail.com> wrote:
Cedric, did you contact the JMockit folks? How did it go?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.




--
Cédric


Reply all
Reply to author
Forward
0 new messages