-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Relates to: #439, #565, #567, #583
ArgumentCaptor can't capture varargs-arrays.
@Test
public void shouldCaptureVarArgsAsArray() throws Exception {
ArgumentCaptor<String[]> varargCaptor = ArgumentCaptor.forClass(String[].class);
mock.varargs("1","2");
verify(mock).varargs(varargCaptor.capture());
assertThat(varargCaptor).containsExactly(new String[]{"1","2"});
}
Expected: A ArgumentCaptor<String[]>
should be able to capture the varargs-array as a whole.
Actual: The ArgumentCaptor captures no arrays but every single argument passed to the varargs method. The following exception is thrown:
java.lang.AssertionError:
Actual and expected should have same size but actual size was:
<2>
while expected size was:
<1>
Actual was:
<["1", "2"]>
Expected was:
<[["1", "2"]]>
dtpmalone, m7stock, Rayman2200, lcardito, sz763 and 4 more