You need to sign in to do that
Don't have an account?
Jean Grey 10
Method defined as TestMethod do not support web service callouts, but I'm not using a callout
I'm getting this error but my code does not have any callouts. I received the same error when I tried to deploy with default test settings, which is what we always use. None of the test classes that threw an error are using callouts. How do I fix this? See code below of one of the test classes that gave an error.
@isTest(seeAllData=true) public class countOppsTest { static testMethod void validateTrigger(){ Test.startTest(); DateTime dateNow = system.now(); Date dateToday = system.today(); Account acct = new Account( name = 'Test Account' ); insert acct; Contact cont = new Contact( accountId = acct.id, firstName = 'Test', lastName = 'Contact', title = 'Test' ); insert cont; Goals__c goal = new Goals__c( Name = 'Test Goal', Amount__c = 1000, Date__c = dateToday, Active__c = TRUE, Opportunity__c = NULL ); insert goal; Opportunity opp = new Opportunity( Name = 'Test Opp', StageName = 'In Purchasing', CloseDate = dateToday, Amount = 1400, AccountId = acct.Id, LeadSource = 'Other' ); insert opp; opp.StageName = 'Closed–Won'; opp.Closed_Won_Reason__c = 'Test'; opp.Closed_Won_Explanation__c = 'Test'; update opp; ID sysAdm = [SELECT Id FROM Profile WHERE Name = 'System Administrator'].Id; //user test data List<User> userList = new List<User>(); User u = new User(ProfileId = sysAdm,LastName = 'last',Email = 'testuser@test.com', Username = 'testuser@test.com' + System.currentTimeMillis(), CompanyName = 'TEST',Title = 'title',Alias = 'alias', TimeZoneSidKey = 'America/Los_Angeles',EmailEncodingKey = 'UTF-8', LanguageLocaleKey = 'en_US',LocaleSidKey = 'en_US'); userList.add(u); insert userList; system.debug('opp '+opp+' goal '+goal); system.assertEquals(goal.Amount__c, 1000); } }
If you are getting this error means somewhere after update/insert it callout is happening. It could be in the process builder(as Apex)/ Trigger on the following objects. Please check below object's Trigger/process builder for any callout.
Account
Contact
Goals__c
Opportunity
User
The above object based on your code samples.
Please let me know if it helps you. Thanks.
Regards,
Pawan Kumar
All Answers
If you are getting this error means somewhere after update/insert it callout is happening. It could be in the process builder(as Apex)/ Trigger on the following objects. Please check below object's Trigger/process builder for any callout.
Account
Contact
Goals__c
Opportunity
User
The above object based on your code samples.
Please let me know if it helps you. Thanks.
Regards,
Pawan Kumar
Irregardless, if I just write a test class that will solve the problem, correct?
since managed package code cannot be changed/viewed so chances to exclude callout is less. Other one will work.
Please mark it best if it was helpful.
Regards,
Pawan Kumar