Click here to Skip to main content
14,241,004 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need to write unit test in junit for a method, the method is inside class A and class A extends Class B. My testing method methodA() calls another methodB() which is inside class B. So how should I mock this methodB() call so that when I call methodA() from my testCase, it get passed?
Which class should I mock, classA or Class B?

What I have tried:

ClassA obj=new ClassA();
ClassB mockClsB=mock(ClassB.class);
when(mockClsB.methodB()).thenReturn(someValue);
int expected=10;
int result=obj.methodA();
Posted
Comments
Gerry Schmitz 26-May-19 14:47pm
   
Ask QA; they're the only ones that care.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100