You need to sign in to do that
Don't have an account?
Beltran Baja
How to write Test Class for simple Apex Class and Trigger
Hi guys, I'm wondering of how I am going to write a Test Class for Apex Class and a Trigger. This is just a simple Class and a Trigger please see below exact codes I am using.
trigger LeadUpdateListener on Lead (after update) { for ( Lead updatedLead : Trigger.New ) { CalloutExternal.pipelineConnect(updatedLead.Id); } }
public class CalloutExternal { @future(callout=true) public static void pipelineConnect (String id) { String token = 'xxxxxxxxx'; HttpRequest request = new HttpRequest(); String endpoint = 'https://xxx.xxxxxxx.com/trigger/'+ token + '/' + id; request.setEndpoint(endpoint); request.setMethod('GET'); HttpResponse response = new HTTP().send(request); System.debug('xxxx Response...' + response); } }I tried creating a Test Class but it doesn't let me through. If anyone who could show me here that would be much appreciated. Thank you!
kinldy find the Test class for your callout trigger,
First you need to create mock Response generatore class since your using call out in your trigger.
Mock reponse class:
after creating this class you need to create test class for your trigge.
this run the test class you can see your trigger and related class code covereage.
hope this solve your issue.
Thanks
karthik
All Answers
kinldy find the Test class for your callout trigger,
First you need to create mock Response generatore class since your using call out in your trigger.
Mock reponse class:
after creating this class you need to create test class for your trigge.
this run the test class you can see your trigger and related class code covereage.
hope this solve your issue.
Thanks
karthik
Thank you very much sir, Cheers!
Does anyone have any idea where I am going wrong here? Thanks guys.
Use this code in Line 22
also share your MockHttpResponseGenerator class
it may help you
Thanks
karthik