here is the quick background:- i wrote a validation rule to restrict the picklist value on user object but there is losts of test claases are getting failed. i choose teh approach to create a helper class to create user test data then i can call. i tried to write the test class not sure it will work please help me with the good approach . how can i can my helper class into my test class
global class TestClassHelper
{
public User CreateUser()
{
//Get a profile id from the data base to assign to our user in this case make them a sys admin
Profile p = [select id from profile where name='System Administrator'];
//Create a new sys admin user and do an insert
User u = new User(alias = 'standt', email='[email protected]',
emailencodingkey='UTF-8', lastname='Testo', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='[email protected]',Resource_Type__c='Employee');
User u1 = [Select u.Profile.Name, u.ProfileId, u.Name, u.Id From User u where u.Profile.Name = 'System Administrator' limit 1];
return u;
}
public User CreateUser(string userType)
{
//Get a profil id from the data base to assign to our user in this case make them a sys admin
Profile p = [select id from profile where name=:userType];
//Create a new sys admin user and do an insert
User ur = new User(alias = 'standt', email='[email protected]',
emailencodingkey='UTF-8', lastname='Testo', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id,
timezonesidkey='America/Los_Angeles', username='[email protected]',Resource_Type__c='Employee');
return ur;
}
}
how can i call both method in my test class.
user u = TestClassHelper.CreateUser();?
i am not sure how i can call public User CreateUser(string userType) user u = TestClassHelper(---) ,what should be argument ?..this is my helper class do i need 2 methods?