You need to sign in to do that
Don't have an account?

Pagereference issue
Hello All,
when i try to cover the below code in the test class. The only first if condition is getting covered and it is not checking or covering the second if condition even if i write another test method in the test class.
And if i remove the return null statement and run the test class, it is covering all the blocks. But the condition is not validating (i.e., not giving any page message) and bypassing the conditions.
Can anyone give me an immediate reply. Would be very helpful.
public pagereference insertPayInfo(){
if(creobj.CC1_Apartment__c=='' || creobj.CC1_Apartment__c == null)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Fatal,'Please Input Postal Code'));
return null;
}
if(creobj.CC1_City_Town__c=='' || creobj.CC1_City_Town__c == null)
{
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Fatal,'Please Input City or Town'));
return null;
}
pagereference pgref=new pagereference('www.salesforce.com');
return pgref;
}
Thanks,
Uday
Please post your testmethod as well to tell you exactly what needs to be done.
As a quick fix, you can update your code as below
All Answers
Please post your testmethod as well to tell you exactly what needs to be done.
As a quick fix, you can update your code as below
Hello Jerun Jose,
Thanks a lot. It worked fine and now my test class is getting coverage and class is also working fine.
:)