@isTest private class SyncLostOppLineItemBatchTest { public static String CurrencyIso = 'CNY'; private static Pricebook2 pricebook = null; private static Product2 product = null; @isTest static void TestMethod01() { product = new Product2( Name = 'テスト商品'); pricebook = ControllerUtil.getStandardPricebook(); //询价 Opportunity opp = new Opportunity(); opp.Name='opp1'; opp.StageName='oppName'; opp.CloseDate=Date.today(); insert opp; //招标项目 Tender_information__c ten = new Tender_information__c(); ten.Name = 'QLMTEST08111057-02'; insert ten; //招标-询价关系 Tender_Opportunity_Link__c tol = new Tender_Opportunity_Link__c(); tol.Opportunity__c = opp.Id; tol.CurrencyIsoCode = 'CNY'; tol.Tender_information__c = ten.Id; StaticParameter.EscapeTOLinkTrigger = true; insert tol; StaticParameter.EscapeTOLinkTrigger = false; //产品 Product2 pro = new Product2(); pro.Name = 'test20240228'; pro.ProductClass__c = '主机'; pro.ProductCategory__c = 'CV主机'; pro.IsActive=true; pro.ProductCode = 'TST1000001'; pro.Asset_Model_No__c = 'TST1000001'; insert pro; //价格手册 PricebookEntry pE = new PricebookEntry( Pricebook2Id = pricebook.Id, Product2Id = pro.Id); pE.UnitPrice = 0; pE.IsActive = true; pE.UseStandardPrice = false; pE.CurrencyIsoCode = CurrencyIso; insert pE; //询价行项目 OpportunityLineItem oli = new OpportunityLineItem(); oli.Quantity = 1; oli.UnitPrice = 0; oli.PricebookEntryId = pE.Id; oli.OpportunityId = opp.id; insert oli; List proList = new List(); proList.add(pro); Test.startTest(); Database.executeBatch (new SyncLostOppLineItemBatch(proList),200); Test.stopTest(); } }