+ Start a Discussion
KevSnellKevSnell 

TestMethod - Integer Count Help

Hey All,


Sorry still trying to understand testmethods and hopefully someone can answer this pretty quickly.

 

I have a controller that does the below for a VF Page:

 

Public static  integer getUnQualified()
    {
    integer UnQualified = [SELECT count() FROM Lead where OwnerId =:UserInfo.getUserId() AND Status='Unqualified' AND IsConverted = False ];
    return UnQualified ;
    }

However how do I write a test method for this?

 

As far as I can understand I need to:

 

Start Test

Set Current Page

New Controller

Insert Lead with Status = Unqualifed

Check that Count returns result

Stop Test

 

My issue is I don't know how to test the count function.

 

Thanks in advance.


Kev

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Rahul SharmaRahul Sharma

getUnQualified() function is simply returning an integer with no parameters.

That means its a get method which returns an integer value.

 

So to cover that function you just have to get the value from that function.

Integer intQ = objClass.getUnQualified();

 

All Answers

Rahul SharmaRahul Sharma

getUnQualified() function is simply returning an integer with no parameters.

That means its a get method which returns an integer value.

 

So to cover that function you just have to get the value from that function.

Integer intQ = objClass.getUnQualified();

 

This was selected as the best answer
KevSnellKevSnell

Thanks - I had just read something that meant I came to the same solution.