You need to sign in to do that
Don't have an account?
ppat
Test Case? using UserInfo.getProfileId() in trigger
I have a trigger which validates based on the user profile Id. Trigger works fine in sandbox. How do I write test case to evaluate different profiles as test class always finds my profile id while executing the trigger
if (UserInfo.getProfileId() != 'Salesforce Administrator') // used Id to compare
{
// Code here
}
any pointers would be great.
if (UserInfo.getProfileId() != 'Salesforce Administrator') // used Id to compare
{
// Code here
}
any pointers would be great.
Did you find out answer?
I am having same problem to write test case to cover userInfo.getUserId().
I find out same way.
Profile pro=new Profile(Name=' Sales User1');
MyControllerExtension ext1 = new MyControllerExtension(new Account(RecordTypeId = '012300000000AGr'),pro);
I tried with controller and it covered till 80%.
So you need to create profile object.set Id to this object in your test method and pass this object with constructor. this way you will get userinfo Id in class.
Thanks for the reponse.I am assuing you are using class with visual pages I am using userinfo method's in trigger and not exactly sure on how to use controllers for getting coverage for trigger .. :smileysad:
Can you point me to documentation where I can find some details on what you are trying ?
Thanks in advance.
-Pramod
True,
I am using controller with visual pages.
Here is my controller with test method.
hope this helps.
And here is link where I got idea.
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=692