Mock an HTTP callout
Tests cannot make real HTTP callouts.
Your task
Finish the mock so the provided HTTP client can be tested with no network, and make your own test register it.
@IsTest
public class AS_0199CD2979A4_Mock implements HttpCalloutMock {
public Integer statusCode = 200;
public String body = '{"ok":true}';
public HttpResponse respond(HttpRequest req) {
return null;
}
@IsTest
public static void fetchesOkBody() {
String result = AS_0199CD2979A4_Client.fetchStatus();
Assert.areEqual('{"ok":true}', result);
}
}Requirements
- returnsOkBody should pass
- throwsOnServerError should pass
- respondUsesItsFields should pass
- learnerTestRegistersTheMock should pass