0

Here is the Code.

public with sharing class page1
{    
   @TestVisible private integer totalRecs = 0;     
   @TestVisible private integer index = 0;
    public integer blockSize = 5;         

    public page1(ApexPages.StandardController controller)
    {
        totalRecs = [select count() from Account where name!= null limit 10];        
    }    

    public List<Account> getaccounts() 
    {
        List<Account> accs = Database.Query('SELECT name, site, Phone, Website, Fax, AccountNumber, Rating FROM Account LIMIT :blockSize OFFSET :index');
        System.debug('Values are ' + accs);
        return accs;
    }    

    public void beginning()
    {
        index = 0;
    }

    public void previous()
    {
        index = index - blockSize;
    }

    public void next()
    {
        index = index + blockSize;
    }

    public void end()
    {
        index = totalrecs - math.mod(totalRecs,blockSize);
    }        

    public boolean getprev()
    {
        if(index == 0)
        return true;
        else
        return false;
    }  

    public boolean getnxt()
    {
        if((index + blockSize) > totalRecs)
        return true;
        else
        return false;
    }         
}

Not able to cover else statement in Boolean method

3
  • Just call those methods like page1 obj = new page1(); obj.getprev();
    – Ratan Paul
    Commented Jan 20, 2016 at 6:44
  • Yeah Ratan. I Did the same but its not cover else part of those methods
    – Bonny
    Commented Jan 20, 2016 at 6:51
  • again set the obj.index =1 then again call obj.getprev(); it will cover the else part as well
    – Ratan Paul
    Commented Jan 20, 2016 at 7:00

1 Answer 1

1

You need to call page1 obj = new page1(); obj.getprev(); getprev method

Also for else part you need to set index obj.index =1 then again call obj.getprev(); it will cover the else part as well

fOR checking put some system.assertequals to check expected value

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .