• Ross Gilbert 8
  • 0 Points
  • Member since 2015

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 0

I've got a visualforce page with a custom controller.  This page simply displays the current user's open leads.  It does not do any DML at all, it simply displays existing leads on a visualforce page.

What I need is a test class for this page and its custom controller.

I'm not sure how to write a test class for this kind of thing.

Here's the visualforce page, called "myLeadsView1":
<apex:page Controller="myLeadListCtr1">
<apex:form >
    &nbsp;&nbsp;&nbsp;<img src="/img/icon/people32.png"/>
    <font size="5">&nbsp;My Open-Uncontacted Leads </font><br></br>
    <h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*Showing my leads, created in the past 6 months, in an 'Open - Not Contacted' status<br></br></h2>
<apex:pageBlock >
    <apex:pageBlockTable value="{!accounts}" var="account">
                                    <apex:column >
                                    <apex:outputlink value="/{!account.Id}">{!account.LastName}</apex:outputLink>
                                    <apex:facet name="header"> Lead Last Name </apex:facet>     
                                    <apex:column >
                                    <apex:outputlink value="/{!account.Id}">{!account.FirstName}</apex:outputLink>
                                    <apex:facet name="header"> Lead First Name </apex:facet>     
                                <apex:column > 
                                    <apex:outputField value="{!account.Response_Needed__c}" />
                                    <apex:facet name="header"> Urgency                                      

                                <apex:column >
                                    <apex:outputLink value="/{!account.Id}">{!account.Status}</apex:outputLink>
                                    <apex:facet name="header"> Status</apex:facet>
        <apex:column value="{!account.Email}"/>
        <apex:column value="{!account.Phone}"/>
        <apex:column value="{!account.CreatedDate}"/>

                    <apex:outputLink target="_blank" value="https://cs15.salesforce.com/00Oe0000000Tb5X" id="theLink">View All My Open  Leads</apex:outputLink>

Here's the customer controller:
public with sharing class myLeadListCtr1 {

    public List<Lead> getAccounts()
        String userId=UserInfo.getUserId();
        return [Select Id,Response_Needed__c,FirstName,LastName,Name,Email,Phone,CreatedDate,Status from Lead WHERE (Status = 'Open - Not Contacted' ) AND CreatedDate = LAST_N_DAYS:180 AND OwnerId =: userId ORDER BY CreatedDate DESC LIMIT 1000  ];


Does anyone know how I might be able to write a good test class for this code?  Since it does no DML, I don't really know how to test this "code".  I put code in parentheses since it's not really code, but rather just a visualforce page that displays existing data.  

Thanks guys.