function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Suresh SatyamSuresh Satyam 

Test Coverage on Objects

Hi,This is Suresh

I have developed a class for this i wrote a test class,but coverage be in 45%only.Can anyone improve this.

Class:

  public GE_EM_Request_Button_Logic(ApexPages.StandardController controller) {

       
            this.Record = (Opportunity)controller.getRecord();
            Record1 = [select id,name from opportunity where id=:record.id];
            string oppname = [select name from opportunity where id =: Record.id].Name;
            string usrObj = UserInfo.getUserId();
            string usrObj1 = UserInfo.getName();
            reqname = new GE_EM_Request__c();
            reqname.GE_EM_Status__c = 'Open';
            reqname.GE_EM_RFQ_Indicator_Value__c = 'G';
            reqname.GE_EM_Opportunity__c = Record.id;
            reqname.Name= oppname;
            
    }    
   
    public PageReference request(){
            system.debug('--------'+reqname);
            string usrObj = UserInfo.getUserId();
            string usrObj1 = UserInfo.getName();
            insert reqname;
            return  new PageReference('/a2c/e?&00NZ0000000mFtb='+reqname.GE_EM_Status__c+'&Name='+reqname.Name+'&00NZ0000000mFxY=G&CF00NZ0000000mFtH__lkid='+usrObj+'&CF00NZ0000000mFtH='+usrObj1+'&recordType=012Z00000000Mv9'+'&CF00NZ0000000m62x__lkid=+record1.id&CF00NZ0000000m62x__lkid=+record1.name');         
    }

-----------------------------------------

Test Class:

 static testmethod void GE_EM_Request_Button_Logictest(){
    
    Opportunity obj = new Opportunity(); 
    ApexPages.StandardController ob = new ApexPages.StandardController(obj); 
    GE_EM_Request_Button_Logic gel = new GE_EM_Request_Button_Logic (ob); 
    
    obj.Name = 'opportunity';  
    obj.CloseDate = system.today(); 
    obj.StageName = 'qualification';  
    insert obj; 
      system.debug('The opp is '+obj);
      
  GE_EM_Request__c gr = new GE_EM_Request__c();   
    gr.GE_EM_Status__c = 'Open';   
    gr.GE_EM_RFQ_Indicator_Value__c = 'g';   
    gr.GE_EM_Opportunity__c = obj.id;   
    gr.name = 'suresh';
    insert gr; 
         gel.request(); 
    }

 

Swamy PSwamy P

Hi Satyam,

                     This Might be helpful,go through this link.If it is suitable with your solution Just Mark as Best Answer.