mockito matchers

Jackie
Aug 16, 2021

when mocking a jdbc query, the statement below was encountering an exception

doReturn("result").when(jdbc).queryForObject(anyString(), String.class);

turns out this was due to mockito, not allowing mix of matcher and raw argument

change above to

doReturn("result").when(jdbc).queryForObject(anyString(), eq(String.class));

worked.

Published

Originally published at https://lwpro2.dev on August 16, 2021.

--

--