You need to sign in to do that
Don't have an account?
Test Coverage on Controller method
Hai,
I have small issue regarding Test Coverage for a method,below is the code,
When I am calling this method through test coverage,it is covering partially. Remaining how to cover can any one tell me. see below comments
public pagereference household(id leadid)
{
pagereference pdfpage = new pagereference('https://c.cs9.visual.force.com/apex/household?leadid='+leadid);
attachment attpdf = new attachment();
attpdf.parentid = leadid; // Upto here the code is covered.
attpdf.body = pdfpage.getcontent(); // from here the code is getting struct and not covering the remaining code.
attpdf.name = 'household.pdf';
attpdf.ContentType = '.pdf';
insert attpdf;
return null;
}
Thanxs,
Sunny.
Test coverages don't support getContent() and getContentAsPDF() methods as of now.
Since this is a straightforward limitation, you can add a condition above your statement where you're calling this method:
if(!Test.isRunningTest())
attpdf.body = pdfpage.getcontent();
* You will call this method only when the apex code is NOT CALLED FROM A TEST COVERAGE.