2 risposte

yes. I use this a lot when doing Test Class Helpers
public static User createUser(String uName, String lName, String eAdd, String alias) {
User user = new User();
user.Username = uName;
user.LastName = lName;
user.Email = eAdd;
user.Alias = alias;
user.TimeZoneSidKey = 'America/New_York';
user.LocaleSidKey = 'en_US';
user.EmailEncodingKey = 'ISO-8859-1';
user.ProfileId = [select id from Profile where Name='System Administrator'].Id;
user.LanguageLocaleKey = 'en_US';
return user;
}
Calling the method
RegardsAndrewUser oldUser = TestClassHelper.createUser('user@name.net','old','dummy@email.net','noalias');
Insert oldUser;