+ Start a Discussion
sfdcrajsfdcraj 

test case....how to pass userinfo to trigger from test class

Hi, 

I am writing a test class for this trigger.

Query in Trigger:
List<PermissionSetAssignment> list1= [select id from PermissionSetAssignment WHERE PermissionSetId IN(select id from permissionSet where label='A') AND AssigneeId=:Userinfo.getUserId()];

Now how to pass the user ID in session info to trigger so that this query returns the rows.

I am creating my test user who is assigned to permission set 'A' in my test class. I just need to pass this user id in session info so that when trigger executes and the list is not empty.


Can any one help me?

Regards,
raj
Best Answer chosen by sfdcraj
Pundareekam KudikalaPundareekam Kudikala


Please refer to below section. You will idea.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm


All Answers

Pundareekam KudikalaPundareekam Kudikala


Please refer to below section. You will idea.
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_testing_tools_runas.htm


This was selected as the best answer
sfdcrajsfdcraj
Hey Pundareekam,

Sorry for the delay!!

Your reply was right on spot. Thanks for the help!!

Regards,
raj