@isTest private class UpdateMonthlyContactBatchTest { @isTest static void test_method_one() { // Implement test code Profile prof = [select Id from Profile where id = :System.Label.ProfileId_SystemAdmin]; List rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; List classDeptStr = new List(); classDeptStr.add('Department_Class_GI'); classDeptStr.add('Department_Class_ET'); classDeptStr.add('Department_Class_BF'); classDeptStr.add('Department_Class_GS'); classDeptStr.add('Department_Class_URO'); classDeptStr.add('Department_Class_GYN'); classDeptStr.add('Department_Class_ENT'); classDeptStr.add('Department_Class_OTH'); List rectDept = [select Id, developername from RecordType where IsActive = true and SobjectType = 'Account' and developername in:classDeptStr]; Map classDeptMap = new Map(); if (rectHp.size() == 0) { return; } for (String Str : classDeptStr) { for (RecordType rt : rectDept) { if (rt.developername == Str) { classDeptMap.put(Str, rt.Id); } } } User hpOwner = new User(Test_staff__c = true, LastName = 'hp', FirstName = 'owner', Alias = 'hp', CommunityNickname = 'hpOwner', Email = 'olympus_hpowner@sunbridge.com', Username = 'olympus_hpowner@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = prof.id); insert hpOwner; Campaign cam = new Campaign(); cam.Name = 'cam'; cam.Name2__c = '1234'; cam.StartDate = Date.today().addDays(15); cam.EndDate = Date.today().addDays(18); insert cam; Account myAccount1 = new Account(name = 'testaccount001', RecordTypeId = rectHp[0].Id, OwnerId = hpOwner.Id ); insert myAccount1; Contact core = new Contact( email = 'jplumber@salesforce.com', firstname = 'Joe', lastname = 'Plumber', accountid = myAccount1.id , Campaign__c = cam.id, JobStatusUpdateDate__c = Date.today() ); insert core; MeetingManagement__c tempMM = new MeetingManagement__c( pollingTime__c = 1, VisitTime__c = 1, InspectTime__c = 1, InspectEquipmentTime__c = 2, TeachingTime__c = 2, MaintenanceReportTime__c = 2, Contact__c = core.id, Campaign__c = cam.id ); Database.executebatch(new UpdateMonthlyContactBatch(), 50); list contactidlist = new list(); contactidlist.add(core.id); Database.executebatch(new UpdateMonthlyContactBatch(contactidlist), 50); Database.executebatch(new UpdateMonthlyContactBatch(core.id), 50); } }