@isTest private class searchAimsAccountTest { public static Account account1 = new Account(); public static Account account2 = new Account(); public static Agency_Hospital_Link__c aHosLink = new Agency_Hospital_Link__c(); static testMethod void testMethod1() { account1.Name = 'test1医院'; account1.RecordTypeId = '01210000000QemG'; insert account1; account2.Name = 'test1经销商'; account2.RecordTypeId = '01210000000Qem1'; insert account2; List accTestList = [SELECT Id, Name FROM Account order by Name]; System.debug('GYFaccTestList='+accTestList); System.assertEquals(10, accTestList.size()); System.assertEquals('test1医院', accTestList[0].Name); //经销商医院データを作る aHosLink.Name = 'test1经销商医院'; aHosLink.Hospital__c = account1.Id; aHosLink.Agency__c = account2.Id; insert aHosLink; //初始化 PageReference page = new PageReference('/apex/searchAimsAccount?accId='+aHosLink.Agency__c); System.Test.setCurrentPage(page); searchAimsAccount sa = new searchAimsAccount(); sa.init(); sa.SearchName = 'test'; sa.serContact(); } }