You need to sign in to do that
Don't have an account?
Waqar Hussain SF
How to write test class for my accountPagination class.
public with sharing class AccountPagination { private final Account acct; // The constructor passes in the standard controller defined // in the markup below public AccountPagination(ApexPages.StandardSetController controller) { this.acct = (Account)controller.getRecord(); } public ApexPages.StandardSetController accountRecords { get { if(accountRecords == null) { accountRecords = new ApexPages.StandardSetController( Database.getQueryLocator([SELECT Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed = true)])); } return accountRecords; } private set; } public List<Account> getAccountPagination() { return (List<Account>) accountRecords.getRecords(); } }
Find below code 100% code coverage
@isTest
public class TestAccountPagination {
public static testmethod void unittest()
{
List<Account> acclist=new List<Account>();
for(Integer i=1;i<15;i++)
{
Account acc=new Account();
acc.Name='My account';
acc.phone='1234567';
//add mandatory fields
acclist.add(acc);
}
insert acclist;
ApexPages.StandardSetController sc = new ApexPages.StandardSetController(acclist);
sc.setSelected(acclist);
AccountPagination scExt = new AccountPagination(sc);
scExt.getAccountPagination();
}
}
this is currect make it as best answer....
thanks,
rajesh..