+ Start a Discussion
Vishal GuptaVishal Gupta 

How to cover the code coverage??

I have a very less idea of how to make the code coverage.So could anybody guide me through it once so that i get some idea.


This class is used as an extension in a VF page. I am fetching the ID of  a record and then navigating to different page on a button click passing that retrieved ID in the next page URL.


public class PortExt
String currentportfolioId;

public PortExt(ApexPages.StandardController controller)

public Pagereference testRedirect()
Pagereference p=new Pagereference('/apex/saveportfolio?id='+ currentportfolioId);
return p;



  It may help you, You should write below code with in the testmethod.


PortExt test1 = new PortExt();


test1. testRedirect();