Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
[no name] 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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900