HttpCallout error System.TypeException: Supplied type is not an interface
When you pass a Type
to the Test.setMock
method, you need to pass the interface being implemented, not the class that implements it.
Joy
Test.setMock(HttpCalloutMock.class, new ProjectCalloutServiceMock());
No Joy
Test.setMock(ProjectCalloutServiceMock.class, new ProjectCalloutServiceMock());
See Testing HTTP Callouts by Implementing the HttpCalloutMock Interface (emphasis added):
For the first argument, pass HttpCalloutMock.class, and for the second argument, pass a new instance of your interface implementation of HttpCalloutMock, as follows:
Test.setMock(HttpCalloutMock.class, new YourHttpCalloutMockImpl());
After this point, if an HTTP callout is invoked in test context, the callout is not made and you receive the mock response you specified in the respond method implementation.