You need to sign in to do that
Don't have an account?

restricted user test cases examples in salesforce?
How to write the restricted user test cases i nsalesforce .please give me the example of above scenario.
You need to sign in to do that
Don't have an account?
you can use user restriction by below sample code....
@isTest(SeeAllData=true)
public class sampletestclass{
static testmethod void testmethod1()
{
// create a new test user
Profile p = [SELECT Id FROM profile WHERE Name = 'System Administrator' LIMIT 1];
User testUser = new User(LastName = 'user 1',
Username = 'user.1@sfdc.com',
Email = 'usersf@gmail..com',
Alias = 'test',
TimeZoneSidKey = 'GMT',
LocaleSidKey = 'en_GB',
EmailEncodingKey = 'ISO-8859-1',
ProfileId = p.Id,
LanguageLocaleKey = 'en_US');
Test.startTest();
System.runas(testUser)
{
.....Do Some Testing...
}
Test.stopTest();
..... assert the results are correct .....
}
}