Created
April 19, 2019 19:37
-
-
Save Nahumancer/3ebb182b3be35331f7cc7dc2331a0eb1 to your computer and use it in GitHub Desktop.
Test User creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void generateTestUser(String randomUserName){ | |
System.runAs ( new User(Id = UserInfo.getUserId()) ) { | |
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; | |
User auxTestUser = new User(); | |
auxTestUser.Alias = 'standt'; | |
auxTestUser.Email = 'testemail@org.com'; | |
auxTestUser.EmailEncodingKey = 'UTF-8'; | |
auxTestUser.LastName = 'Test'; | |
auxTestUser.LanguageLocaleKey = 'en_US'; | |
auxTestUser.LocaleSidKey = 'en_US'; | |
auxTestUser.ProfileId = p.Id; | |
auxTestUser.TimeZoneSidKey = 'America/Los_Angeles'; | |
auxTestUser.Username = randomUserName; | |
insert auxTestUser; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To be used like this: