You need to sign in to do that
Don't have an account?
SS Karthick
Test Class for pagination
Hi folks,
Can anyone tell me how to write the test class for pagination?
Below is my test class which covers 85% but it didnt covers the hasnext,previous and pagenumber method.
Controller:
Thanks in advance
Karthick
Can anyone tell me how to write the test class for pagination?
Below is my test class which covers 85% but it didnt covers the hasnext,previous and pagenumber method.
@isTest(SeeAllData=true) public class PaginationControllerTest { public static testMethod void testSearchAccount() { PageReference pageRef = Page.TestPagination; Test.setCurrentPage(pageRef); // Instantiate a new controller with all parameters in the page PaginationController p=new PaginationController (); p.getAccountList(); p.Next(); p.First(); p.Last(); p.Previous(); p.Cancel(); p.con.getHasPrevious(); p.con.getHasNext(); p.con.getPageNumber(); } }
Controller:
public class PaginationController { public ApexPages.StandardSetController con { get { if(con == null) { con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name,Type FROM Account])); con.setPageSize(5); } return con; } set; } public List<Account> getAccountList(){ return (List<Account>)con.getRecords(); } public Boolean hasNext { get { return con.getHasNext(); } set; } public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } public Integer pageNumber { get { return con.getPageNumber(); } set; } public void first() { con.first(); } public void last() { con.last(); } public void previous() { con.previous(); } public void next() { con.next(); } public void cancel() { con.cancel(); } }
Thanks in advance
Karthick
Here is the sample for your code:
http://salesforce.stackexchange.com/questions/58453/how-to-write-the-test-class-for-pagination
Thanks,
Pratik
All Answers
Here is the sample for your code:
http://salesforce.stackexchange.com/questions/58453/how-to-write-the-test-class-for-pagination
Thanks,
Pratik
Thanks,
Pratik
I tried your code, the run test failed, although it raised my code coverage from 19% to 34%