Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (3.5k points)

Is there a way to capture a list of specific type using mockitos ArgumentCaptore. This doesn't work:

ArgumentCaptor<ArrayList<SomeType>> argument = ArgumentCaptor.forClass(ArrayList.class);

1 Answer

0 votes
by (46k points)

The nested generics-problem can be bypassed amidst the @Captor annotation:


public class Test{


    private Service service;


    private ArgumentCaptor<ArrayList<SomeType>> captor;


    public void init(){




    public void shouldDoStuffWithListValues() {





Browse Categories