Jmockit NullPointerException with Junit - java

I'm trying to run a test that written by another programmer with JUnit in eclipse-indigo, and he is sure it works but when I try Jmockit there is a failure and I can't find a solution, yet.
I try to change jmockit.jar in classpath but not working. Do you have any idea about this problem?
Edit: When I use "ant test" in terminal there is no problem but if I click run as > JUnit test in my IDE I got this error.
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.NullPointerException
at mockit.internal.state.TestRun.getInstance(TestRun.java:40)
at mockit.internal.state.TestRun.mockFixture(TestRun.java:111)
at mockit.internal.ClassFile.createClassFileReader(ClassFile.java:33)
at mockit.internal.annotations.AnnotatedMockMethodCollector.collectMockMethods(AnnotatedMockMethodCollector.java:39)
at mockit.internal.RedefinitionEngine.<init>(RedefinitionEngine.java:86)
at mockit.internal.RedefinitionEngine.<init>(RedefinitionEngine.java:110)
at mockit.internal.startup.Startup.setUpInternalStartupMock(Startup.java:130)
at mockit.internal.startup.Startup.loadInternalStartupMocksForJUnitIntegration(Startup.java:112)
at mockit.internal.startup.Startup.initialize(Startup.java:79)
at mockit.internal.startup.Startup.agentmain(Startup.java:69)
... 6 more
Agent failed to start!
[WARN ][load ] agent library 'instrument' failed to init with result: 102
java.lang.RuntimeException: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
at mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:130)
at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:80)
at mockit.internal.startup.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:41)
at mockit.internal.startup.Startup.initializeIfNeeded(Startup.java:244)
at org.junit.runner.Runner.<clinit>(Runner.java:25)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:13)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:30)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:455)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:684)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:391)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent failed to initialize
at sun.tools.attach.HotSpotVirtualMachine.loadAgent(HotSpotVirtualMachine.java:122)
at mockit.internal.startup.JDK6AgentLoader.loadAgentAndDetachFromThisVM(JDK6AgentLoader.java:123)
at mockit.internal.startup.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:81)
... 16 more
java.lang.NoClassDefFoundError: org/junit/internal/runners/ErrorReportingRunner
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

As you stated in your comment you set an extra argument to the execution in ant.
Try setting
-javaagent:libtest/jmockit.jar
as a VM Argument (its the second input field on the Arguments tab) in the launch configuration for your junit test.
And make sure that the classpath is the same as in ant.

If you have the zip file of the distribution around, it should be pretty easy to just debug this and see why it's getting the NPE. Just add the source attachment as the zip file.

Related

Intellij Junit causes java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

I am trying to integrate sendgrid into one of our repo's that handles emails. But my Junit tests keep throwing the mentioned Exception. I've skimmed through most of the posts on here talking about running the jar and issues around cglib and I do have the latest Mockito-all (1.10.19) pulled down. I'm able to build the jar and get it to run after excluding the signature files but my question is how do I get the Junit to work??
Basically all I'm doing is trying to mock the SendGrid class.
private SendGrid mockApiClient = Mockito.mock(SendGrid.class);
Here's how I've included it in the project: (yes thats ivy)
<dependency org="com.sendgrid" name="sendgrid-java" rev="4.6.5" conf="uber-jar->default"/>
The stacktrace of the exception thrown is as follows:
java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:330)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:263)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:318)
at java.util.jar.JarVerifier.update(JarVerifier.java:230)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:383)
at java.util.jar.JarFile.ensureInitialization(JarFile.java:617)
at java.util.jar.JavaUtilJarAccessImpl.ensureInitialization(JavaUtilJarAccessImpl.java:69)
at sun.misc.URLClassPath$JarLoader$2.getManifest(URLClassPath.java:991)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:451)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2611)
at java.lang.Class.getDeclaredFields(Class.java:1944)
at org.junit.runners.model.TestClass.<init>(TestClass.java:49)
at org.junit.runners.ParentRunner.<init>(ParentRunner.java:75)
at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:57)
at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
This was occurring because I had a fat jar downloaded from a while back. When I removed that, cleared my cache and re-pulled everything I was able to get a jar which did not have those signature files.
Everything now works

JVMJ9VM007E Command-line option unrecognised: -javaagent

I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK.
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.chubb.prssearchpolicy.test.PRSSearchPolicyResourceTest.init(PRSSearchPolicyResourceTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:136)
at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:53)
at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
at mockit.Invocations.<clinit>(Invocations.java:26)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
... 24 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: Unable to enqueue operation: the target VM does not support attach mechanism
at sun.tools.attach.WindowsVirtualMachine.<init>(WindowsVirtualMachine.java:64)
at sun.tools.attach.WindowsAttachProvider.attachVirtualMachine(WindowsAttachProvider.java:64)
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:213)
at mockit.internal.startup.AgentLoader.attachToRunningVM(AgentLoader.java:133)
... 29 more
For This I passes VM argument in run configuration but getting following error:
JVMJ9VM007E Command-line option unrecognised: -javaagent=C:\Users\junit\jmockit.jar
Has anyone faced this issue? Response will be greatly appreciated.
Can you try adding the following parameter -Dcom.ibm.tools.attach.enable=yes also jdk tools.jar file should be in your classpath
Also please have a look into this post which is strikingly similar to yours. According to the accepted answer there was a bug in one of the distributions which needs to have TestNG in the classpath as workaround.
AttachNotSupportedException while running jMockit tests on IBM JRE

Issue with Jenkins Junit cases running with maven

from last few week, I am facing a strange issue regarding the junit test case in the jenkins, when I say strange the same workspace if I try to run from the command prompt working fine and execute the junit test case but when running with jenkin it is throwing error for junit as test case UNC paths are not supported. Defaulting to Windows directory. and lso class not found. and the error is:
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # projectdemo ---
[INFO] Surefire report directory: MBP\workspace\target\surefire-reports
MBP\workspace'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
... 4 more
Caused by: java.lang.RuntimeException: Unable to create test class 'com.db.proj.demo.services.integration.impl.test.TestImpl'
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:109)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:164)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:86)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:105)
... 12 more
[ERROR] There are test failures.
Please refer to MBP\workspace\target\surefire-reports for the individual test results.
It is working fine till few day backs, but I don't if anything else need to declared for junit to pass in jenkin.
Note: I have declared a maven project in jenkin with svn as source repository.
In my humble opinion, the error is clear: java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl
You should revise that in your svn repository the TestImpl class changes has been committed. If the problem persists, try to configure your Jenkins project to an older version in which you are sure it used to compile fine. Step by step, you are likely to find out what problem has been introduced, but it is bound to be related to a non-commit class.

Jenkins Cobertura build - NoClassDefFoundError

I have a test class ProcessorTest with the lines
JSONObject jsonObj = XML.toJSONObject(convert);
DBOb = (DBObject) JSON.parse(jsonObj.toString());
The XML class is from json.org. The class is used else where in the code without a problem.
Everything runs fine on localhost (i.e., all Maven and JUnit tests execute).
When I pushed to Jenkins I get this error:
Jenkins Error
Error Details
net/sourceforge/cobertura/coveragedata/TouchCollector
Stack Trace
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at org.json.XML.__cobertura_init(XML.java)
at org.json.XML.<clinit>(XML.java)
at ProcessorTest.classSetup(ProcessorTest.java:81)
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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 26 more
I'm using Jenkins 1.553 and the Cobertura plugin 1.9.6.
How do I fix this?
The project structure is like this:
-- project1
|
| - core
| - Tests (includes the tests that fail)
-- org.json
|
| - XML.class
When pushed to Jenkins I assume the org.json project is unavailable for the tests.
This exception and stack trace is misleading; it actually results from not having SLF4J + ch.qos.logback included in your classpath (the .ant/lib path or some other classpath available to ant). Cobertura (up to and including 2.1.1, at least) has a specific requirement for the ch.qos.logback SLF4J implementation. If this SLF4J implementation is not included, then the following stack trace can result:
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at [org.package.ClassName].__cobertura_init([ClassName].java)
at [org.package.ClassName].<clinit>([ClassName].java)
at [org.package.ClassName]Test.[method]([ClassName]Test.java:113)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
In my case, I already had slf4j-simple-1.7.14.jar in my .ant/lib classpath, and I needed to remove it and replace it with logback-core-1.0.13.jar and logback-classic-1.0.13.jar. After that, my instrumented test cases executed without this exception.
Seems like you have a Java version different in your Jenkins machine. Try to install exactly the same version than you have on local.
More info here: https://github.com/cobertura/cobertura/issues/52
This strange behavior could also be related to a different Maven version on your Jenkins build machine than you use locally. It would also be of interest which version of the cobertura-maven-plugin you are using in your pom.xml.
The pure Cobertura library itself (bundled with the maven plugin of your project) uses a bunch of dependencies which might be in conflict with the Cobertura integration of the Jenkins environment. Try to check for asm.jar in your dependency tree. Maybe this causes runtime trouble in the jenkins environment as well.
A setup that works in my institution (with projects that include org.json dependencies):
latest Jenkins version 1.596 in combination with the Jenkins Cobertura-Plugin 1.9.6
latest cobertura-maven-plugin maven plugin for various projects in version 2.6
My strong guess: It is not about the JSON stuff itself, but about the environment of your setup; your Jenkins version 1.553 is a bit outdated. I would advice you to go for an upgrade if possible with your admins/other projects.

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:
How to update IntelliJ IDEA testing-plugin to TestNG version 6.8?

Categories

Resources