You need to sign in to do that
Don't have an account?
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...