+ Start a Discussion
priyanka.mv26priyanka.mv26 

Code coverage

hi am posting my code here.. pls provide me the test class,, thanks a lot.. its urgent.. plssss

 

public with sharing class RelatedListController
{
private Account accnt;
public integer max{get; set;}
public boolean visible{get;set;}
public String alphabet{get; set;}
public string soql{get;set;}
public ApexPages.StandardSetController paginationController {get;set;}
private boolean IsFiltered;
public void passAlphabet()
{
alphabet= ApexPages.CurrentPage().getParameters().get('alphabet');
IsFiltered = true;
}
public RelatedListController(ApexPages.StandardController controller)
{
this.accnt = (Account)controller.getRecord();
}
public ApexPages.StandardSetController setCon
{
get
{
string query;
if(setcon == null || IsFiltered==true)
{
IsFiltered =False;
if(alphabet == 'A'|| alphabet == 'B' || alphabet == 'C' || alphabet == 'D'|| alphabet == 'E' || alphabet == 'F' || alphabet == 'G' || alphabet == 'H' || alphabet == 'I' || alphabet == 'J' || alphabet == 'K' || alphabet == 'L' || alphabet == 'M' || alphabet == 'N' || alphabet == 'O' || alphabet == 'P' || alphabet == 'Q' || alphabet == 'R' || alphabet == 'S' || alphabet == 'T' || alphabet == 'U' || alphabet == 'V' || alphabet == 'W' || alphabet == 'X' || alphabet == 'Y' || alphabet == 'Z')
{
/* some query */
}
else if(alphabet == 'Other')
{
/* some query */
}
else
{
/* some query */
}
setCon = new ApexPages.StandardSetController(Database.getQueryLocator(query));
max = setCon.getResultSize();
if(max > 20)
{
visible = true;
}
else
{
visible = false;
}
}
return setCon;
}
set;
}
public List<Inventor__c> getInventors()
{
return (List<Inventor__c>) setCon.getRecords();
}
public List<InvWrapper> getInventorsWithIndex()
{
List<Inventor__c> invs = this.getInventors();
List<InvWrapper> InvWrappered = new List<InvWrapper>();
Integer idex = 1;
for (Inventor__c inv : invs)
{
InvWrappered.add(new InvWrapper(inv, idex));
idex++;
}
return InvWrappered;
}
public class InvWrapper
{
public Inventor__c inv { get; set; }
public Integer tabIndex { get; set; }
public ApexPages.StandardSetController paginationController {get;set;}
public InvWrapper(Inventor__c inv, Integer tabIndex)
{
this.inv = inv;
this.tabIndex = tabIndex;
}
}
public Boolean hasNext
{
get
{
return setCon.getHasNext();
}
set;
}
public Boolean hasPrevious
{
get
{
return setCon.getHasPrevious();
}
set;
}
public Integer pageNumber
{
get
{
return setCon.getPageNumber();
}
set;
}
public void first()
{
setCon.first();
}
public void last()
{
setCon.last();
}
public void previous()
{
setCon.previous();
}
public void next()
{
setCon.next();
}
public void cancel()
{
setCon.cancel();
}
}

RadnipRadnip

Hi, you can find out how to test code in Salesforce here:

 

http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods

 

Without knowing the context of the code and how its used its hard to work out what positive and negative tests are needed to check the code is working correctly. Also you have seemed to have removed the queries. Depending on what they are you may have different tests to check different types of records with different information stored against them.

Rajesh SriramuluRajesh Sriramulu

Hi

 

Create the object for RelatedListController and pass the methods and insert the values and pass teh methods with that object

and create another object for inner class InvWrapper like this

outerclass.innerclass rt = new outerclass.innerclass();

 

and pass the methods under this class with that object.