Loading tutorials
@IsTest methods, and that you know how Http, HttpRequest, and HttpResponse work. The mock itself comes in the next chapter. Here you shape the production code so the mock is easy to apply and most of the logic needs no mock.2 min read@IsTest methods, and that you know HTTP methods, status codes, and JSON. It also assumes you have seen the Http, HttpRequest, and HttpResponse classes. Here you will build the mock that replaces the real HTTP call in a test.2 min read@IsTest methods, and that you know the HttpCalloutMock interface from the previous chapter. Here you connect a mock to the code under test. The step is small, but it is where most first-time callout tests fail.2 min read@IsTest classes, and read HTTP status codes and JSON. Apex blocks real callouts during tests, so every callout test registers a mock first. Here you combine a service class, a mock class, and Test.setMock into one passing test.2 min read@IsTest, you know HTTP status codes, and you have already written a first callout test with Test.setMock. The code under test is WeatherService.getCondition, which throws a WeatherException for any status other than 200.2 min readHttpCalloutMock and register it with Test.setMock. It also assumes you have seen a single-callout test like the ones for WeatherService.2 min readHttpCalloutMock and register it with Test.setMock, as covered earlier. It also assumes you know how to find Static Resources in Setup or in a Salesforce DX project.2 min read@IsTest classes, use Test.setMock with an HttpCalloutMock, and read the WeatherService class from earlier chapters. Here you will see why a test can fail with an "uncommitted work pending" error and how Test.startTest avoids it.2 min readTest.setMock registers an HttpCalloutMock, and have seen the WeatherService and WeatherServiceMock classes from earlier chapters. Here you will test callouts that run in asynchronous Apex, where the code does not run in the same 2 min readHttpCalloutMock and Test.setMock work together. It also helps to know that Apex generates classes from a WSDL file.2 min readHttpCalloutMock, register it with Test.setMock, and run a test with @IsTest. You should also know basic HTTP status codes and JSON.2 min read