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
Miriam LückeMiriam Lücke 

http request test coverage problems

I have a http request method and I can't figure out how to cover my code. Can anybody help?
public static String basicAuthCallout(String PaymillToken, String Endpoint)
		String PrivateKey = 'private';
		String PaymentId = 'wrong';
		HttpRequest req = new HttpRequest();

 		//Set token for http request

		 // Specify the required password to access the endpoint (Private key)
		 // As well as the header and header information
		 Blob headerValue = Blob.valueOf(PrivateKey);
		 String authorizationHeader = 'BASIC ' +
		 req.setHeader('Authorization', authorizationHeader);
		 // Create a new http object to send the request object
		 // A response object is generated as a result of the request  

		Http http = new Http();
		HTTPResponse res = http.send(req);
		String response = res.getBody();
		integer startPoint = response.IndexOf('pay');
		if(startPoint > 0)
			String temp = response.subString(startPoint);
			integer EndString = startPoint + temp.IndexOf('\",');
			PaymentId = response.subString(startPoint, EndString);
		return PaymentId;

You'll want to read up on these two articles.  Afterwards, if you have any specific issues, please include any tests that you have written and we can try to help you figure it out.