function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CooldayCoolday 

How to write the test class for this piece of code?

Code 
if(response.getStatusCode() != 200){
                exception e = new exception();
                e.setMessage(response.toString());
                HandleCustomException.LogException(e,payload,null);
            }

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

As mentioned in the below article you can use mock class and set the statucode there.

https://jayakrishnasfdc.wordpress.com/2021/01/02/apex-test-class-examples-for-web-services/

If this solution helps, Please mark it as best answer.

Thanks,