简体   繁体   中英

Initializing Jmockit with Intellij idea WARNING

I am having issue running jmockit on idea. I have testng test case that uses jmockit to mock. I am getting:

WARNING: JMockit was initialized on demand, which may cause certain tests to fail;
please check the documentation for better ways to get it initialized.
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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:108)
Caused by: java.lang.NullPointerException
    at mockit.internal.startup.Startup.redefineMethods(Startup.java:184)
    at mockit.internal.startup.Startup.redefineMethods(Startup.java:176)
    at mockit.internal.annotations.MockClassSetup.applyClassModifications(MockClassSetup.java:190)
    at mockit.internal.annotations.MockClassSetup.redefineMethodsInClassHierarchy(MockClassSetup.java:151)
    at mockit.internal.annotations.MockClassSetup.redefineMethods(MockClassSetup.java:140)
    at mockit.Mockit.setUpMocks(Mockit.java:249)
    at mockit.integration.testng.internal.TestNGRunnerDecorator.<init>(TestNGRunnerDecorator.java:67)
    at mockit.integration.testng.internal.TestNGRunnerDecorator.registerWithTestNG(TestNGRunnerDecorator.java:60)
    at mockit.integration.testng.Initializer.<init>(Initializer.java:29)
    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 java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:48)
    at org.testng.TestNG.setListenerClasses(TestNG.java:637)
    at org.testng.TestNG.configure(TestNG.java:1372)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:187)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:111)

Here is the order of jars: 在此处输入图片说明

Here in part 4 it is telling what is the order and i am making this order but still getting warning which later is causing problem.

Anyone knows what is the problem? I am using

  • jdk1.6.0_25
  • Intellij idea 11.1.2
  • testng-6.3.1
  • jmockit-0.999.16

You are using incomplete TestNG jar from Maven, you need to use the full distribution from the TestNG site ( testng.org/testng-xxx.zip ), see this answers for the details:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM