mockito matchers

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s