You need to sign in to do that
Don't have an account?
Need Test Class for the ABC Apex class
Hi,
How to write Test Case for the below Apex class..
public class ABC {
public PageReference callfun() {
Boolean flag= false;
User usr= [SELECT Use_Policy__c from User where Id=:UserInfo.getUserId() and IsActive=true];
if(usr.Use_Policy__c) {
PageReference pageRef = Page.UsePolicySuccess;
pageRef.setRedirect(true);
return pageRef;
} else{
PageReference pageRef = Page.UsePolicyPage;
pageRef.setRedirect(true);
return pageRef;
}
}
}
Your feedback is appreciated..
Hi,
your class with test mtehod
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
But every time test coverage executed for positive path. how to make it to execute else part.
Best practice is to always stage your data in a Test Method - and to never statically declare variables within a Method.
If you did something like this: