+ Start a Discussion
Greg CooganGreg Coogan 

RunAs As Existing User in Test Class

All documentation and articles I have found create a new test user to be used with the RunAs method in a Test Class. How would I run as an existing user, such as an "Integration User" we have? I don't want to create a new user in the Test Class.
Best Answer chosen by Greg Coogan
Without using seeAllData = true we can't access the org data but it's not recommended to use seeAllData = 'True' in the test class the test class will fail if you don't have the particular user in your org then the test will fail. So I recommend you to create a new user in the test class with the user profile same as your Integration userCreation of test data or test user in salesforce org won't  store in the org or send any notification.