Wednesday, 28 August 2019

junit mockito function call verify

the most useful funcdtions are :


then you can use the Captor to capture the value when saveAll function is called.

List<CustomerSex> list = cosCaptor.getValue();

you need to make sure you have the captor setup:


private ArgumentCaptor<List<CustomerSex>> cosCaptor;

you may need:


public MockitoRule rule = MockitoJUnit.rule();

cannot remember detail....

note:  "verify(coDao).saveAll(cosCaptor.capture());"  this also expect saveAll just get called only one time.

expect to throw excepction:


No comments:

Post a comment