• chubsub2
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies

I'm only getting 14% coverage on the custom controller.  The controller basically lists fields that contain formula values onto a Visualforce page.  If a check box is checked on a record, the field will display on the Visualforce page.

 

Below is the error message which highlights the code that isn't covered in red, but I'm not sure how to go about writing test code to cover them. 

 

Thanks in advance to anyone that can help,

 

Here's a link to the image:

http://www.flickr.com

 

 

 

 

 

I'm only getting 14% coverage with the test method below, any advise?

 

Visualforce page:

<apex:page controller="CustomPage" showHeader="true" >
<table>
<tr>
<td>
<apex:dataTable value="{!List}" var="r">
<apex:column value="{!r.Name}"/>
</apex:dataTable>
</td>
</tr>
</apex:page>

 

 

Controller:

public class IngList {
  // ApexPages.StandardSetController must be instantiated  
    
  // for standard list controllers  
    
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select name, from CustomObject__c WHERE custom_check_box_field__c = true]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records  
    
    public List<CustomObject__c> getList() {
         return (List<CustomObject__c>) setCon.getRecords();
    }
}

 

 

 

 

Test Class:

@isTest

private class TestIngList {

static testMethod void testIngList(){
    ApexPages.StandardSetController setCon;
    PageReference pageRef = Page.CustomPage;

Custom_Object__c cusobj = new Custom_Object__c();
cusobj.custom_check_box_field__c = true;
insert cusobj;

List<CustomObject__c> cus = new List<Custom_Object__c>{};

System.assertNotEquals(null, cusobj.Id);
    Test.setCurrentPage(pageRef);
    IngList controller = new IngList();

}
}

 

 

Thanks in Advance!

I'm only getting 14% coverage on the custom controller.  The controller basically lists fields that contain formula values onto a Visualforce page.  If a check box is checked on a record, the field will display on the Visualforce page.

 

Below is the error message which highlights the code that isn't covered in red, but I'm not sure how to go about writing test code to cover them. 

 

Thanks in advance to anyone that can help,

 

Here's a link to the image:

http://www.flickr.com

 

 

 

 

 

I'm only getting 14% coverage with the test method below, any advise?

 

Visualforce page:

<apex:page controller="CustomPage" showHeader="true" >
<table>
<tr>
<td>
<apex:dataTable value="{!List}" var="r">
<apex:column value="{!r.Name}"/>
</apex:dataTable>
</td>
</tr>
</apex:page>

 

 

Controller:

public class IngList {
  // ApexPages.StandardSetController must be instantiated  
    
  // for standard list controllers  
    
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(
                      [select name, from CustomObject__c WHERE custom_check_box_field__c = true]));
            }
            return setCon;
        }
        set;
    }

    // Initialize setCon and return a list of records  
    
    public List<CustomObject__c> getList() {
         return (List<CustomObject__c>) setCon.getRecords();
    }
}

 

 

 

 

Test Class:

@isTest

private class TestIngList {

static testMethod void testIngList(){
    ApexPages.StandardSetController setCon;
    PageReference pageRef = Page.CustomPage;

Custom_Object__c cusobj = new Custom_Object__c();
cusobj.custom_check_box_field__c = true;
insert cusobj;

List<CustomObject__c> cus = new List<Custom_Object__c>{};

System.assertNotEquals(null, cusobj.Id);
    Test.setCurrentPage(pageRef);
    IngList controller = new IngList();

}
}

 

 

Thanks in Advance!