Thursday, March 7, 2013

Create User record in Test Method in Salesforce Apex

Salesforce.com is working on providing developers with a better testing environment. Salesforce.com requires you to write test cases to deploy code to production.You’ll need to create all of your test records and test each scenario to ensure your code performs as expected.
Here’s a small test class for Creating User record.


@isTest
private class Test_CreateUser{

Profile pfl = [select id from profile where name='Standard User'];
User testUser = new User(alias = 'db', email='deepabalib@mfs.com',
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
            localesidkey='en_US', profileid = pfl.Id,  country='United States',
            CommunityNickname = 'u1',timezonesidkey='America/Los_Angeles',
            username='deepabali@mindfiresolutions.com');
insert  testUser;

}


No comments:

Post a Comment