@isTest private class AccountVisitCountControllerTest { static testMethod void myUnitTest() { // データ作成 RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; Account hospital = new Account(); hospital.RecordTypeId = rectCo.Id; hospital.Name = 'TestHospital'; insert hospital; PageReference page = new PageReference('/apex/AccountVisitCount?id=' + hospital.Id); System.Test.setCurrentPage(page); AccountVisitCountController controller = new AccountVisitCountController(new ApexPages.StandardController(hospital)); Account2__c acc2 = [Select Id, Account_Org__c from Account2__c where Account_Org__c = :hospital.Id]; System.assertEquals(acc2.Id, controller.acc2.Id); } }