I'm using TestNG for testing and JMockit for mocking mockMethod(). Here's the test case:
@Test public void testClass1() { new MockUp<MyInterface>() { @Mock public int myMethod(final MyObject someObject ){ return 0; } }; MyObject obj = new MyObject(); Assert.assertEquals(obj.mockMethod(someObject),0); } }
The mockMethod() I'm calling for assertEquals() looks like this:
public class Class1 { MyInterface my; public int mockMethod(final MyObject someObject ){ ...... //processing steps return my.myMethod(someObject); } }
Test case throws a Null pointer exception. What am I doing wrong? Do I mock the implementation of mockMethod()? I tried that too, but it hasn't worked.