Tasty Test Tip: Using ArgumentCaptor for generic collections with Mockito - JDriven
Tasty Test Tip: Using ArgumentCaptor for generic collections with Mockito Posted on For example: However, when using generic typed objects, some problems rise up. For example, the following won't work: ArgumentCaptor- > argument = ArgumentCaptor.forClass(List
- > argument = ArgumentCaptor.forClass(List
- > argumentCaptor; 1 2 @Captor private ArgumentCaptor
- > argumentCaptor; 2. initialize the Mockito annotations in your initialization method (add one if you don't have one). @Before public void init(){ MockitoAnnotations.initMocks(this); } 1 2 3 4 @Before } And presto! You can now capture the parameters that were used when a to be verified method was executed. verify(someMock).
Read full article from Tasty Test Tip: Using ArgumentCaptor for generic collections with Mockito - JDriven
No comments:
Post a Comment