@isTest private class CloseTaskUpdateBatchTest { static testMethod void myUnitTest() { Profile p = [select id from Profile where id =:System.Label.ProfileId_SystemAdmin]; User u1 = new User(); u1.LastName = '_サンブリッジ'; u1.FirstName = 'あ'; u1.Alias = 'あ'; u1.Email = 'olympusTest01@sunbridge.com'; u1.Username = 'olympusTest01@sunbridge.com'; u1.CommunityNickname = 'olympusTest01@sunbridge.com'; u1.IsActive = true; u1.EmailEncodingKey = 'ISO-2022-JP'; u1.TimeZoneSidKey = 'Asia/Tokyo'; u1.LocaleSidKey = 'ja_JP'; u1.LanguageLocaleKey = 'ja'; u1.ProfileId = p.id; u1.Job_Category__c = '销售服务'; u1.Province__c = '東京'; u1.Post__c = '部长'; insert u1; task__c t1 = new task__c(); t1.Name = 'test'; t1.taskDifferent__c = '主动任务'; t1.taskStatus__c = '02 接受'; t1.assignee__c = u1.Id; insert t1; System.RunAs(new User(Id = Userinfo.getUserId())){ Test.startTest(); u1.IsActive = false; update u1; Test.stopTest(); } } }