function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BoolsEyeBoolsEye 

UserInfo.getUserId() available in a testMethod ?

Is it possible to call the UserInfo.getUserId() in a testMethod and do I always get a valid User Id when uploading my package ?
 
Are the tests run under a generic user Id and this method will return NULL instead of a valid user id ?
 
Anyone used this before ? I add events for this user id in my test methods and wonder if this will work in all cases.
 
Thanks.
eliotstock2eliotstock2
When running your unit tests in the IDE, the user is yourself, ie. the user you're logged in to salesforce.com as in your project properties. UserInfo.getUserId() works in a test method and will give you your own user ID.