Thursday, 15 August 2013

java - Invalid use of argument matchers!0 matchers expected, 1 recorded -



java - Invalid use of argument matchers!0 matchers expected, 1 recorded -

although error quite descriptive not hang of it. lines:

powermockito.when( mockstringmessageservice.lookupstring(matchers.eq("xyz"))) .thenreturn(matchers.eq("xyz"));

error is:

[junit] invalid utilize of argument matchers! [junit] 0 matchers expected, 1 recorded: [junit] -> @ com.amazon.kilvish.types.statustabletest.setup(statustabletest.java:61) [junit] [junit] exception may occur if matchers combined raw values: [junit] //incorrect: [junit] somemethod(anyobject(), "raw string"); [junit] when using matchers, arguments have provided matchers. [junit] example: [junit] //correct: [junit] somemethod(anyobject(), eq("string matcher")); [junit] [junit] more info see javadoc matchers class.

why 0 matchers expected?

you cannot utilize matchers in thenreturn clause. utilize string literal instead:

powermockito.when( mockstringmessageservice.lookupstring(matchers.eq("xyz"))) .thenreturn("xyz");

java unit-testing junit mockito

No comments:

Post a Comment