--Hey I'm using Mockito and TestNG to write a unit test for a class that's making a lot of external calls to a service, I'm actually quite new to this hence I seem to be stuck with little documentation on the net for my exact problem.
my test looks like this basically
@Test public class ClassToTestTest{ @Mock private Object1 object1; @Mock private Object2 object2; @InjectMocks private ClassToTest classToTest; public void test1(){ classToTest.methodToTest(); } ... ... }
The actual class is as follows
import FinalClass; public class ClassToTest{ private Object1 object1; private Object2 object2; public void methodToTest(){ object2 = FinalClass.getObject2(); ... ... } ... ... }
I just need FinalClass.getObject2() to return the mock of Object2 That I've created in my Test, I know I can mock FinalClass using PowerMock, but I'm not quite getting how to inject it in the classToTest that I've created, so that when I run the classToTest.methodToTest() from my test object2 is initialized with my mocked implementation.
Thanks in Advance!
You received this message because you are subscribed to the Google Groups "mockito" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/bfvrDHeFkXgJ.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.