机会测试班

问题描述 投票:0回答:0

@isTest 公共类 TestFlowClass {

@TestSetup
static void createTestData(){
    List<Opportunity> parentOppList = new List<Opportunity>();
    parentOppList.add(new Opportunity(Name='Test Opp1',CloseDate=system.today()+30,Probability=10,StageName='Prospecting',Type='New Customer'));
    parentOppList.add(new Opportunity(Name='Test Opp2',CloseDate=system.today()+30,Probability=10,StageName='Prospecting',Type='New Customer'));
    insert parentOppList;
    
    List<Opportunity> childOppList = new List<Opportunity>();
    childOppList.add(new Opportunity(Name='Test Opp1',CloseDate=system.today()+30,Probability=10,StageName='Prospecting',Type='New Customer',Parent_opportunity__C=parentOppList[0].Id));
    childOppList.add(new Opportunity(Name='Test Opp2',CloseDate=system.today()+30,Probability=10,StageName='Prospecting',Type='New Customer',Parent_opportunity__C=parentOppList[1].Id));
    insert childOppList;
}

@IsTest
static void test1(){
    List<Opportunity> childOppList = [SELECT Id FROM Opportunity WHERE Parent_opportunity__C=null];
}

}

这是编写流程并检查其中元素的测试类

salesforce internals test-class
© www.soinside.com 2019 - 2024. All rights reserved.