@isTest private class AgencyHospitalLinkBatchTest { public static Account account1 = new Account(); public static Account account2 = new Account(); public static Agency_Hospital_Link__c aHosLink = new Agency_Hospital_Link__c(); private static void testInit() { // 取引先 account1.Name = 'test1医院'; account1.RecordTypeId = '01210000000QemG'; insert account1; account2.Name = 'test1经销商'; account2.RecordTypeId = '01210000000Qem1'; insert account2; //经销商医院データを作る aHosLink.Name = 'test1经销商医院'; aHosLink.Hospital__c = account1.Id; aHosLink.Agency__c = account2.Id; insert aHosLink; //经销商医院名前を変更する aHosLink.Name = 'test经销商医院1'; aHosLink.Hospital__c = account1.Id; aHosLink.Agency__c = account2.Id; update aHosLink; account1.Name = 'test1医院1122333'; account1.RecordTypeId = '01210000000QemG'; update account1; } static testMethod void testMethod1() { AgencyHospitalLinkBatchTest.testInit(); Agency_Hospital_Link__c ahl = [select id,isSame__c,Hospital_Name_readonly__c,Name,Hospital__r.Name from Agency_Hospital_Link__c where id = :aHosLink.id]; System.debug(ahl.Hospital_Name_readonly__c); System.debug(ahl.id); System.debug(ahl.Name); System.debug(ahl.Hospital__c); System.debug(ahl.isSame__c); Database.executeBatch(new AgencyHospitalLinkBatch(),2); } // 2021-03-10 mzy WLIG-BYHD79 SFDC环境batch合并调查 start static testMethod void testMethod2() { AgencyHospitalLinkBatchTest.testInit(); Agency_Hospital_Link__c ahl = [select id,isSame__c,Hospital_Name_readonly__c,Name,Hospital__r.Name from Agency_Hospital_Link__c where id = :aHosLink.id]; System.debug(ahl.Hospital_Name_readonly__c); System.debug(ahl.id); System.debug(ahl.Name); System.debug(ahl.Hospital__c); System.debug(ahl.isSame__c); Database.executeBatch(new AgencyHospitalLinkBatch(true),2); } // 2021-03-10 mzy WLIG-BYHD79 SFDC环境batch合并调查 end }