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
shruthikashruthika 

urgent:Increase code coverage

Hi all,


I have written test class for merging trigger and the code coverage is about 56% .. could anyone help me out in increasing code coverage please give me the solution as soon as possible.

 

Below is the code which i have written...



@isTest
private class MQLTEST
{
    static testMethod void myUnitTest()
    {
    // try catch block is used to remove the System.NullPointerException
        try
        {
     //   The format of the String depends on the local date format.
            Date t = date.today();
            Date d = Date.newInstance(t.year(),t.month(),t.day());
               
     //  Query the StageName,MQL Promotion Date, MQL Rejection Date from the standard object ie., Opportunity
                   
            Opportunity opp = [Select StageName, MQL_Promotion_Date__c, MQL_Rejection_Date__c from Opportunity WHERE Name = 'Mql Test'];
           
     //Displays the Stage name in debug log    
                   
            System.debug(' Val '+opp.StageName);
           
     //Returns a Date that contains the value of the specified String. The String should use the standard date format “yyyy-MM-dd HH:mm:ss” in the local time zone  
                
            System.debug('Opp MQl Date Val '+string.valueof(opp.MQL_Promotion_Date__c));
    
     //Checks the       
                   
            if(opp.StageName=='Lead' || opp.StageName=='Qualified Lead')
            {
     //Update the  StageName as D - Qualify
      
                opp.StageName = 'D - Qualify';
                system.debug('** updating test opportunity ');
                update opp;
               
     //Displays the Stage name in debug log           
               
                system.debug(' StageName '+ opp.StageName ); 
               
    // get updated account to verify trigger made correct updates
   
             Opportunity  getOpportunity = [Select StageName from Opportunity WHERE Name = 'Mql Test'];     
            
   
     //Only process if StageName is not equal to either Lead, Qualified Lead or No Opportunity         
               
                if(opp.StageName != 'Lead' && opp.StageName != 'Qualified Lead' && opp.StageName != 'No Opportunity')
                {        
                    System.debug('*** Oppty changed from Lead to something other than Lead or No Opportunity - date set to ' + System.today()+' ****');
                    system.debug(opp.MQL_Promotion_Date__c.isSameDay(d));
                    System.assertEquals(getOpportunity.MQL_Promotion_Date__c,System.today());
                }
                       
    //Only process if StageName is equal No Opportunity
   
                if(opp.StageName == 'No Opportunity')
                {                
                    System.debug('*** Oppty changed from Lead to No Opportunity-date set to'+System.today() +'****');
                    system.debug(opp.MQL_Rejection_Date__c.isSameDay(d));
                    System.assertEquals(getOpportunity.MQL_Rejection_Date__c,System.today());
                }
            } // End of If statement 
        }
       
        catch(Exception e)
        {
            system.debug('Error'+ e);
        }
    }
} // End of MQLTEST

 


 

Thanks in advance.....

shruthika...



Glen.ax1034Glen.ax1034
  string onepercentcoverage;
  string twopercentcoverage;
  string threepercentcoverage;
  string fourpercentcoverage;
  string fivepercentcoverage;
  string sixpercentcoverage;
  string onepercedntcoverage;
  string twopercedntcoverage;
  string threepedrcentcoverage;
  string fourperdcentcoverage;
  string fiveperdcentcoverage;
  string sixdpercentcoverage;
  string fourperrcentcoverage;
  string fiveperceyntcoverage;
  string sixpercenttcoverage;
  string onepercednrtcoverage;
  string twopercednutcoverage;
  string threepedrcfentcoverage;
  string fourperdcefntcoverage;
  string fiveperdcedntcoverage;
  string sixdpercentcovderage;
  string twopercutcoverage;
  string threepedcfentcoverage;
  string fourperdcecoverage;
  string fiveperdcettdntcoverage;
  string sixdpercetrntcovderage;