Oleg Siboglov
04/29/2020, 8:52 PMfun foo(int: Int = 0, string: String = "")
verify(someMock).foo(int = intCaptor.capture)
Currently Mockito is throwing a InvalidUseOfMatchersException
, claiming its expecting 5 matchers (actual number of parameters) and instead it only recorded one. Im hoping theres a better approach than creating 5 different captors.Brian Saltz Jr
04/29/2020, 9:10 PMany()
or eq(value)
. You’d still have to provide all 5 parameters, but you don’t need to provide a captor for each one. You just can’t mix captors/matchers with actual values, which is what your .foo()
call is doing in your example.Oleg Siboglov
04/29/2020, 9:12 PMBrian Saltz Jr
04/29/2020, 9:12 PMverify(someMock).foo(int = intCaptor.capture(), string = "")
So it’s mixing a real value (""
) with a captor/matcher. You can do this to fix it:
verify(someMock).foo(int = intCaptor.capture(), string = eq(""))
Or instead of eq("")
, use any()
if you truly don’t care if it’s using the default or not.Brian Saltz Jr
04/29/2020, 9:12 PM