@isTest private class testBeforeInsertUpdateOnUser { static testMethod void myUnitTest() { User targetUser = [SELECT Id, LastName, FirstName, Alias, Alias__c FROM User WHERE Id = :userInfo.getUserId()]; targetUser.LastName = 'last'; targetUser.FirstName = 'First'; update targetUser; User targetUser02 = [SELECT Id, LastName, FirstName, Alias, Alias__c FROM User WHERE Id = :userInfo.getUserId()]; System.assertEquals( 'lastFirst', targetUser02.Alias__c, '001'); } }