@isTest private class TotalPriceWebServiceTest{ @TestSetup public static void setup() { MaintanceContractPack__c mcp = new MaintanceContractPack__c(); mcp.Contract_Type__c='上限合同'; insert mcp; MaintanceContractPackEstimate__c mcpe = new MaintanceContractPackEstimate__c(); mcpe.MaintanceContractPack__c = mcp.Id; insert mcpe; Maintenance_Contract__c mc1 = new Maintenance_Contract__c(); mc1.MaintanceContractPack__c = mcp.Id; mc1.Department__c ='0011000001diPRx'; insert mc1; Maintenance_Contract__c mc2 = new Maintenance_Contract__c(); mc2.Department__c ='0011000001diPRx'; insert mc2; } @isTest public static void testCanAddMc() { Test.StartTest(); MaintanceContractPack__c mcp = new MaintanceContractPack__c(); mcp.Contract_Type__c='上限合同'; insert mcp; TotalPriceWebService.canAddMc(mcp.Id); MaintanceContractPackEstimate__c mcpe = new MaintanceContractPackEstimate__c(); mcpe.MaintanceContractPack__c = mcp.Id; mcpe.Decide__c = true; insert mcpe; TotalPriceWebService.canAddMc(mcp.Id); MaintanceContractPackEstimate__c mcpe2 = new MaintanceContractPackEstimate__c(); mcpe2.MaintanceContractPack__c = mcp.Id; mcpe2.Process_Status__c = '申请中'; insert mcpe2; TotalPriceWebService.canAddMc(mcp.Id); Test.stopTest(); } }