I want to test a method that creates an ArrayList<String>
. I want to capture what it puts into the list. How do I create a MockedConstruction<ArrayList<String>>
? For example:
try(MockedConstruction<ArrayList<String>> arrayListMockedConstruction = /* what to put here? */)) {
myClass.myMethod();
ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.captor();
when(arrayListMockedConstruction.constructed().add(stringArgumentCaptor.capture())).thenReturn(true);
} catch (Exception e) {
fail();
}
Isn't there a way to create a mocked construction like with the captor()
method for ArgumentCaptor
, or maybe an annotation for a field of the test class?