I wanted to also invoke the original mocked target object in the test. In the state based Mockup API one does this by adding a mockit.Invocation as the first argument to the method signature.
Then, the original mocked object is available via: invocation.getInvokedInstance().
It does not work in Eclipse 4.2. I copied the same code and opened the source in Eclipse 3.7. It works. Thus, the issue is Eclipse or a setup difference.
May 19, 2013: I see that the classpath ordering is different as shown in the .classpath config file. Also, the JRE_CONTAINER is different, the one in the Eclipse 4.2 project is using JavaSE-1.7. That should have been jdk1.7.0_13. Will have to retest.
That wasn’t the issue.
- Windows 7 64bit, AMD PC
- JDK 1.7
- Eclipse 4.2
- JUnit 4
- JMockIt 1.2
- Mock Java time and date using JMockIt
- Search Java classpath for JUnit tests using Spring
- Java JMockIt mocks via Spring DI
- Use AOP Aspects as Mocks in JUnit tests?
- Unit testing Java exception handling using JMockIt