Method does not exist or incorrect signature in Test.setMock
A common cause of this sort of error is a variable (called "test" or "Test") hiding the static class method reference Test.setMock
. But if you have posted the complete source code it would not be that.
Saving this first:
@isTest
global class WebServiceMockImpl implements WebServiceMock {
global void doInvoke(
Object stub,
Object request,
Map<String, Object> response,
String endpoint,
String soapAction,
String requestName,
String responseNS,
String responseName,
String responseType) {
}
}
and then this:
@isTest
private class WebSvcCalloutTest {
@isTest static void testEchoString() {
Account a = new Account(name='Tester');
insert a;
// This causes a fake response to be generated
Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
}
}
compiles fine in my org even taking the "Salesforce.com API" version back to 18.0.
I suggest to track down the cause you simplify until it compiles and then add code back in until it doesn't.
PS
The issue was shadowing, but probably by a separate class not a variable in the class (based on the comments below). Adding the system namespace prefix:
System.Test.setMock(...);
works around both types of shadowing.