+ Start a Discussion
Jerry ClifftJerry Clifft 

Increasing controller test class coverage

The visualforce and contoller class seem to work fine, but I am having a hard time increasing the test class cod coverage from 9%.
 
Visual Force Page
<apex:page Controller="SLMFGRaExt" sidebar="False" showHeader="False" docType="html-5.0">  
<apex:panelGrid columns="1"  cellpadding="2" width="800" >
</apex:panelGrid>

<apex:panelGrid columns="1"  cellpadding="2" width="650">
<apex:form >
    <apex:pageBlock >
        <apex:pageBlockTable value="{!sbx}" var="s" width="400px" columns="4" columnsWidth="75px, 75px, 75px, 100px">
            
            <apex:column >
                <apex:facet name="header">S/N</apex:facet>
                <apex:outputText label="S/N" value="{!s.Serial_Number__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">RA #</apex:facet>
                <apex:inputText label="RA #" value="{!s.RA_Number__c}"/>            
            </apex:column>
            


        </apex:pageBlockTable>
	<apex:commandButton value="Save" action="{!onsave}" />
</apex:pageBlock>
</apex:form>
</apex:panelGrid>
</apex:page>
Controller

public class SLMFGRaExt {

    public SLMFGRaExt() {

    }
    public SLMFGRaExt(ApexPages.StandardController controller) {
    }
    public ApexPages.StandardSetController setCon {
        get {
            if(setCon == null && ApexPages.currentPage().getParameters().get('cid') != null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT ID, Name, RA_Number__c, Serial_Number__c, CASEID__c FROM Sbx__c WHERE CASEID__c = :ApexPages.currentPage().getParameters().get('cid') AND AND RA_Number__c = NULL ORDER BY Sbx__c.Name ]));
                }
            return setCon;
        }set;
		}
    public List<Sbx__c> getSbx() {
         return (List<Sbx__c>) setCon.getRecords();
    }


    public PageReference onsave() {
        update (List<Sbx__c>) setCon.getRecords();

        return new PageReference('http://the.force.com/sbx/Sbx_ThankYou');
    }
}
Test Class

@isTest (seeAllData=true)
Public class SLMFGRaExt_test{

    public static testMethod void SbxExt_1(){
        Account a = new Account();
        a.Name = 'Test Account';
        a.phone = '(303) 555-5555';
              
        insert a;
        
    Opportunity o = new Opportunity();
       o.Name='Tet Opp';
       o.AccountId=a.Id;
       o.RecordTypeId='0126000000053vu';
       o.CloseDate=system.Today();
       o.StageName='Closed Won';
       
       insert o;
       
    Case c1 = new Case();
        c1.Opportunity__c=o.Id;
        c1.Account_Name__c=a.Id;
        c1.Status='Form Sumitted';
        
        insert c1;


      Sbx__c sb = new Sbx__c();
          sb.Serial_Number__c='L98765';
          sb.RA_Number__c='R12345';
          sb.CaseID__c=c1.id;
          sb.Opportunity__c=o.id;
          
          Insert sb;    
    
    PageReference pageRef = Page.SbxLMFG_RAEntry;
		Test.setCurrentPage(pageRef);
    system.test.setCurrentPage(pageRef);
    
    ApexPages.StandardController setCon = new ApexPages.standardController(sb);
    SbxLMFGRaExt ext = new SbxLMFGRaExt(setCon);

    System.currentPagereference().getParameters().put('cid',c1.Id);


  }
  
  }