//create by rentx 2020-12-16 @isTest private class searchHospitalControllerTest { static testMethod void testMethod1() { //建一个医院 Account hospital = new Account(); hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.Is_Active__c = '有効'; hospital.Attribute_Type__c = '卫生部'; hospital.Speciality_Type__c = '综合医院'; hospital.Grade__c = '一级'; hospital.OCM_Category__c = 'SLTV'; hospital.Is_Medical__c = '医疗机构'; // hospital.State_Master__c = al.id; // hospital.City_Master__c = al2.id; hospital.Town__c = '东京'; insert hospital; //建一条医院特价产品 hospitalprice__c hc = new hospitalprice__c(); hc.hospital__c = hospital.Id; hc.aph__c = '12332'; insert hc; PageReference page = new PageReference('/apex/searchHospital'); page.setRedirect(true); System.Test.setCurrentPage(page); searchHospitalController conTest = new searchHospitalController(); conTest.init(); conTest.SearchName = 'test'; conTest.serContact(); } }