Loading tutorials
@IsTest class is. It also assumes you know HTTP methods, status codes, and JSON. Every callout test in this tutorial depends on three built-in classes. A mock builds an HttpResponse, reads an HttpRequest, and stands5 min read@IsTest methods. It also assumes you know the Http, HttpRequest, and HttpResponse classes from the previous chapter, and that you are comfortable with HTTP status codes and JSON. You will not write a mock yet. That comes in t5 min read@IsTest test classes, and that you know HTTP methods, status codes, and JSON. It also assumes you have read the earlier chapters on why tests cannot make real callouts and on the Http, HttpRequest, and HttpResponse classes.5 min readTest.setMock connects a mock class to the code under test. It assumes you can write Apex classes and @IsTest methods, and that you have already implemented HttpCalloutMock (the previous chapter). You also need to know what an HttpRequest and HttpResponse are.4 min read@IsTest methods, and that you know HTTP methods, status codes, and JSON. You will test the WeatherService class from earlier chapters with a mock. By the end you will have a passing success test and an error test, and you will know why each lin4 min read@IsTest classes, you know how HttpCalloutMock and Test.setMock fit together from the previous chapters, and you know HTTP status codes and JSON. The examples reuse WeatherService, WeatherServiceMock, and the success test from earlier.4 min read@IsTest. It also assumes you have already built a mock with HttpCalloutMock and registered it with Test.setMock, as in the earlier chapters. You should know what an HTTP method, a header, and a JSON body are.5 min readHttpCalloutMock, register it with Test.setMock, and write a basic callout test, as covered in the earlier chapters. You should also be comfortable with Map and List in Apex.5 min read@IsTest, that you have already written a custom HttpCalloutMock (such as WeatherServiceMock), and that you know how to create a static resource in Salesforce. It builds on the first callout test from the earlier chapters.5 min read@IsTest, you know the WeatherService and WeatherServiceMock classes from earlier chapters, and you know what a transaction is in Apex. It covers one common failure: a test that passes its mock setup but still fails with an "uncommitted 5 min read@future methods, Queueable jobs, and Batch Apex. This chapter shows how to test them with the same HttpCalloutMock you used earlier, and how to assert on what the job actually did.5 min readHttpCalloutMock and Test.setMock. You should know why Apex tests cannot make real callouts, and you should be comfortable writing a test class with @IsTest. You don't need to know SOAP in depth. You do need to know that SOAP is an olde5 min readHttpCalloutMock, register it with Test.setMock, and write basic success and error tests. It covers the habits that keep callout tests reliable and the errors you are most likely to hit.4 min read