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
David Durant 5David Durant 5 

TestMethod does not support Web service callouts Error

I have a test class and trigger that I have completed. Currently, it is giving me an error on the web services callout. I tried to do some research to understand why it was giving me this error. I know that the piclist field that I am referencing has a web service callout on the lead object but I am refereing to it on the opportunity.  I also do not know where or how to even set up the mock callout to allow myself to obtain code coverage. Can anybody offer any advice on where to start?

I read both 
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm

And 

https://help.salesforce.com/apex/HTViewSolution?id=000138850&language=en_US

I understand that I need to build a mock web service but I have no idea where to start. 


Here is my code:
@isTest
public class TestUtilityUpdate{
    static testMethod void myTest(){
        Account acc= new Account(name='Test - Properties');
        insert acc;
        
        set<String> strNames = new set<String>{'Los Angeles Department of Water and Power',
            'Adams Ranch',
            'Amarillo Mutual',
            'Anaheim, City of',
            'Arcadia, City of'
            };

        List<Opportunity> lstOpp = new List<Opportunity>();

        for(String str : strNames)
        {
           Opportunity opp = new Opportunity(Water_Agency__c=str,name=str,closedate=system.today(),stagename='Consult to be Scheduled',Accountid=acc.id);
            lstOpp.add(opp);
        }

insert lstOpp;
    
    }
}

 
Amit Chaudhary 8Amit Chaudhary 8
Hi David Durant 5,

Please post your account and opportunity trigger code
Himanshu ParasharHimanshu Parashar
Hi David,

I think we fixed that. :)


Thanks,
Himanshu