Questions tagged [system.runas]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer

runAs() not working as expected

When I run the following piece of code: @isTest private static void testKybc() { String methodName = 'testKybc'; ObjectUtil.debugLogBegin('TMPTriggerHandler_Test', methodName, ''); Map&...
Fabien Braconnier's user avatar
0 votes
1 answer

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'); } ...
pincet's user avatar
  • 869
0 votes
1 answer

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 = ...
Krishna Chaitanya's user avatar
0 votes
0 answers

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 ...
Kevin S's user avatar
  • 13
0 votes
0 answers

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 ...
SfdcBat's user avatar
  • 4,791
4 votes
1 answer

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 ...
Edmondo's user avatar
  • 1,712