You need to sign in to do that
Don't have an account?
buggs sfdc
Help need with code coverage for standard controller pagination
HI,
can anyone help me to cover the test class for the following class.i keep on getting an error like:
can anyone help me to cover the test class for the following class.i keep on getting an error like:
"Error: Compile Error: Constructor not defined: [acccont].<Constructor>(ApexPages.StandardSetController) at line 5 column 34"
public class acccont { public acccont(ApexPages.StandardController controller){} public list<acccont> zsubLst{get;set;} public ApexPages.StandardSetController cont { get { if(cont == null) { cont = new ApexPages.StandardSetController(Database.getQueryLocator([select,id,name(Select id,Firstname from Contacts) From Account where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active'])); } return cont; } set; } public List< acccont > samp{ get { cont.setPageSize(5); return (List<acccont>) cont.getRecords(); } } // returns the first page of records public void first() { cont.first(); } // returns the last page of records public void previous() { cont.previous(); } public void last() { cont.last(); } public void next() { cont.next(); } public Boolean hasNext { get { return cont.getHasNext(); } set; } // indicates whether there are more records before the current page set. public Boolean hasPrevious { get { return cont.getHasPrevious(); } set; } }
@isTest(seealldata = true) private class acccontTest { static testMethod void testsub(){ List<acccont> lst =[select,id,name(Select id,Firstname from Contacts) From Account where Accountid = :ApexPages.currentPage().getParameters().get('id') AND Status__c = 'Active']); acccont sc = new acccont(new ApexPages.StandardSetController( lst )); } }
Here is the sample for your code:
http://salesforce.stackexchange.com/questions/58453/how-to-write-the-test-class-for-pagination