+ Start a Discussion
luccilucci 

How to cover this string in Test class?

accId = EncodingUtil.urlEncode((ApexPages.currentPage().getParameters().get('accId')==null)?'':ApexPages.currentPage().getParameters().get('accId'), 'UTF-8');

 

Thanks in advance

~Onkar~Onkar

Try This in your test class.

 

PageReference pageRef = Page.<<Your Page>>;
Test.setCurrentPage(pageRef);

thecontroller <<Your Controller>> = new <<Your Controller>>();
// Add parameters to page URL

ApexPages.currentPage().getParameters().put('accId', '122344444');

 

 

~Onkar Kumar