I'm creating a test method where I have to create a test user. I will be using runAs
for this. But, in creating the actual test user, I'm unsure how to set profile items such as PermissionsApiUserOnly
. Here is my code so far (taken from documentation):
Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
User u = new User(Alias = 'standt', Email='[email protected]',
EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
LocaleSidKey='en_US', ProfileId = p.Id,
TimeZoneSidKey='America/New_York', UserName='[email protected]',
Profile.PermissionsApiUserOnly='true');
But, I get
Invalid field Initializer error on Profile.PermissionsApiUserOnly
Any help would be greatly appreciated. Thanks!