• Eddie Vazquez
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I'm a new admin for my org, when I try to run the test classes one of them fails and the error I receive is "Methods defined as TestMethod do not support Web service callouts Stack Trace: null". How do I resolve this? Here's my test class:

@isTest
public class TaskRelatedRecordStatus_Test {

    static Task tTask1;
    static Task tTask2;
    static Task tTask3;
    static Account tAccount1;
    static Account tAccount2;
    static Opportunity tOppty1;
    static Lead tLead1;

    static void createTestData(){
        tAccount1 = new Account(Name = 'Testco', Account_Status__c = '01 - Cold');
        tAccount2 = new Account(Name = 'Other Testco', Account_Status__c = '00 - Raw');
        INSERT tAccount1;
        INSERT tAccount2;

        tOppty1 = new Opportunity(Name = 'Widgets', StageName = '01 - Identifying an Opportunity', CloseDate = date.valueOf('2018-09-09'), AccountID = [SELECT Id FROM Account WHERE Name = 'Other Testco'].Id);
        tLead1 = new Lead(Company = 'ABCCo', Status='01 - New', LastName='Dodd');

        INSERT tOppty1;
        INSERT tLead1;
       
        tTask1 = new Task(whatID = [SELECT Id FROM Account WHERE Name = 'Testco'].Id);
        tTask2 = new Task(whatID = [SELECT Id FROM Opportunity WHERE Name = 'Widgets'].Id);
        tTask3 = new Task(whoID = [SELECT Id FROM Lead WHERE Company = 'ABCco'].Id);
        
        INSERT tTask1;
        INSERT tTask2;
        INSERT tTask3;

    }

    testMethod
    static void triggerInAction(){
        test.startTest();
            
        createTestData();

        tTask1 = [SELECT Account_Status__c FROM Task WHERE Id = :tTask1.Id];
        tTask2 = [SELECT Opp_Status__c FROM Task WHERE Id = :tTask2.Id];
        tTask3 = [SELECT Lead_Status__c FROM Task WHERE Id = :tTask3.Id];

        test.stopTest();

        System.assertEquals(tTask1.Account_Status__c, '01 - Cold');
        System.assertEquals(tTask2.Opp_Status__c, '01 - Identifying an Opportunity');
        System.assertEquals(tTask3.Lead_Status__c, '01 - New');
    }
}
I'm a new admin for my org, when I try to run the test classes one of them fails and the error I receive is "Methods defined as TestMethod do not support Web service callouts Stack Trace: null". How do I resolve this? Here's my test class:

@isTest
public class TaskRelatedRecordStatus_Test {

    static Task tTask1;
    static Task tTask2;
    static Task tTask3;
    static Account tAccount1;
    static Account tAccount2;
    static Opportunity tOppty1;
    static Lead tLead1;

    static void createTestData(){
        tAccount1 = new Account(Name = 'Testco', Account_Status__c = '01 - Cold');
        tAccount2 = new Account(Name = 'Other Testco', Account_Status__c = '00 - Raw');
        INSERT tAccount1;
        INSERT tAccount2;

        tOppty1 = new Opportunity(Name = 'Widgets', StageName = '01 - Identifying an Opportunity', CloseDate = date.valueOf('2018-09-09'), AccountID = [SELECT Id FROM Account WHERE Name = 'Other Testco'].Id);
        tLead1 = new Lead(Company = 'ABCCo', Status='01 - New', LastName='Dodd');

        INSERT tOppty1;
        INSERT tLead1;
       
        tTask1 = new Task(whatID = [SELECT Id FROM Account WHERE Name = 'Testco'].Id);
        tTask2 = new Task(whatID = [SELECT Id FROM Opportunity WHERE Name = 'Widgets'].Id);
        tTask3 = new Task(whoID = [SELECT Id FROM Lead WHERE Company = 'ABCco'].Id);
        
        INSERT tTask1;
        INSERT tTask2;
        INSERT tTask3;

    }

    testMethod
    static void triggerInAction(){
        test.startTest();
            
        createTestData();

        tTask1 = [SELECT Account_Status__c FROM Task WHERE Id = :tTask1.Id];
        tTask2 = [SELECT Opp_Status__c FROM Task WHERE Id = :tTask2.Id];
        tTask3 = [SELECT Lead_Status__c FROM Task WHERE Id = :tTask3.Id];

        test.stopTest();

        System.assertEquals(tTask1.Account_Status__c, '01 - Cold');
        System.assertEquals(tTask2.Opp_Status__c, '01 - Identifying an Opportunity');
        System.assertEquals(tTask3.Lead_Status__c, '01 - New');
    }
}