Questions tagged [system.runas]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
31 views

system.runAs() doesn't throw an exception when user doesn't have permission

Let's say we have Boolean wasAuraException = false; system.runAs(TEST_DUMMY_USER) { try { DataWrapper data = MyController.getData('mockValue'); } ...
0
votes
1answer
23 views

Setup and NonSetup object insertion in Test Class

we've a factory class method to create sObject: Class: DataFactory: public static SObject createSObject(SObject sObj, String defaultClassName, Boolean doInsert) { SObject retObject = ...
0
votes
0answers
163 views

Test Class for system.runas(user) not working for UserInfo.getUserId Coverage

Im stuck at 52% coverage of a vf controller that queries and displays timecards__c records of UserInfo.getUserId in a table. What is basically not getting covered is the if else statements after the ...
0
votes
0answers
121 views

system runAs method to verify if the user can access a record

I have below test class which verifies whether a use have access to the record or not. The Campaign__C object's sharing setting is Private. However with below test class when I run the SOQL the 2nd ...
4
votes
1answer
1k views

What are the limitations of System.runAs?

Unfortunately it seems that there is some undocumented behaviour with System.runAs and creating users in Apex tests. In particular we observed, with API 45: If we run a test class that we do not ...