Question: public void whenAddCalledRealMethodCalled ( ) { doCallRealMethod ( ) . when ( myList ) . add ( any ( Integer . class ) ) ;

public void whenAddCalledRealMethodCalled(){ doCallRealMethod().when(myList).add(any (Integer.class)); myList.size(); verify(myList, times(1)).size(); assertEquals(15, result);
Which of the following statements is true regarding the whenAddCalledRealMethodCalled test method?
Pick ONE option
It passes Test successfully. It will call ArrayList's add real method call and it will add 15 to list.
It will fail. It's call to ArrayList's add method is working but it's mocked and get method is gonna return null. It will fail at
assertEquals(15, result);
The code won't complie. You can't mock ArrayList.class for List
 public void whenAddCalledRealMethodCalled(){ doCallRealMethod().when(myList).add(any (Integer.class)); myList.size(); verify(myList, times(1)).size(); assertEquals(15, result); Which

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!