How to capture a list of specific type with mockito

后端 未结 8 1591
天命终不由人
天命终不由人 2020-12-12 10:05

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

ArgumentCaptor> argumen         


        
8条回答
  •  一整个雨季
    2020-12-12 11:06

    If you're not afraid of old java-style (non type safe generic) semantics, this also works and is simple'ish:

    ArgumentCaptor argument = ArgumentCaptor.forClass(List.class);
    verify(subject.method(argument.capture()); // run your code
    List list = argument.getValue(); // first captured List, etc.
    

提交回复
热议问题