@isTest private class lexRentalApplyControllerTest { @TestSetup static void makeData(){ Rental_Apply__c raObj = new Rental_Apply__c(); raObj.Name = 'testra'; raObj.Status__c = '草案中'; raObj.Product_category__c = 'GI'; raObj.Demo_purpose1__c = '产品试用'; raObj.direct_send__c = '医疗机构'; raObj.Loaner_received_staff__c = '王五'; raObj.Loaner_received_staff_phone__c = '110'; raObj.direct_shippment_address__c = '北京市'; raObj.Hope_Lonaer_date_Num__c = 1; // 希望借用天数 raObj.Phone_number__c = '1234567890'; raObj.Follow_pcl_status2_Text__c = '引合 : -'; raObj.demo_purpose2__c = '其他' ; insert raObj; } static testMethod void test1(){ Rental_Apply__c ra = [select Id from Rental_Apply__c limit 1]; Test.startTest(); lexRentalApplyController.initForCreateOPDFromRentalApply(ra.Id); lexRentalApplyController.initForCreateOPDFromRentalApply(''); Test.stopTest(); } }