Reputation: 307
I'm trying to mock an interface class using JMockit, following the example in the documentation. However, im getting an error saying that
java.lang.IllegalArgumentException: Matching real methods not found for the following mocks: package.JMockitTest$1#HttpResponse(package.HttpClient client)
@Test
public void mockingAnInterface() throws Exception
{
HttpClient client = new MockUp<HttpClient>() {
@Mock
String HttpResponse(HttpClient client)
{
return "100";
}
}.getMockInstance();
Weblogic weblogic = new Weblogic();
Assert.assertEquals(client.HttpResponse("asd"), "100");
}
Upvotes: 0
Views: 1649
Reputation: 10132
You are passing a String
at line client.HttpResponse("asd"), "100"
while your mocked method expects a HttpClient
You need to mock method,
@Mock
String HttpResponse(String client)
{
return "100";
}
in your MockUP
OR
You need to change your call to use HttpClient
instead of String
Upvotes: 1