+ Start a Discussion
Code+1Code+1 

Help required in test class code coverage

Hello All,
This is an email service class.. 
 Please find my test class below. Kindly help me in writing the test class for this.
 
 Email Service Class

Thank You !!
Shashikant SharmaShashikant Sharma
Could you share your test class code. Although as the coverage looks you just need to make 

task.Project_Apprroval__c = 'Approved';
task.Status__c = 'Open';

in your test class code.

Thanks
Shashikant
 
Amit Chaudhary 8Amit Chaudhary 8
Please check below blog. That will help u on test classes
http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html

Please try below code i hope that will help u
@isTest 
public class TriggerTestClass 
{
	static testMethod void testMethod1() 
	{
		Task__c task = new Task__c();
		task.Project_Apprroval__c = 'Approved';
		task.Status__c = 'Open';
		// Add all required field here.
		// task.task_executioner_1__C =
		insert task;

		
	}
}
Please let us know if this will help you

Thanks
Amit Chaudhary


 
Code+1Code+1
Hi Shashikanth/Amit,

Thanks for your reply !!
Please find the test class code --
I am finding difficulties in traversing into nested if's like ----- if() { if(){} }

@isTest(seeAllData = True)
public class IPMO_Taskflagupdatetest{
  
  static testMethod void generate3(){
        String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'Project__c' and Name = 'AXA BSG'].Id;
        User strUserId = [SELECT Id FROM User where Name = 'Nishikanth Nandiraju'];
        Contact strContactId = [SELECT Id FROM Contact where Name = 'Nishikanth Nandiraju'];
        Project__c proj = new Project__c();
        Integer i;
        proj.Name = 'Test Project';
        proj.Department_Name__c = 'AXA BSG';
        proj.RecordTypeId = strRecordTypeId ;
        proj.Project_Manager__c = strUserId.id ;
        proj.AXA_BS_Project_Sponsor__c = strUserId.id ;
        proj.Start_Date__c = System.today();
        proj.End_Date__c = System.today()+10;
        proj.Number__c =[select count() from Project__c where RecordTypeId =: strRecordTypeId ];
        proj.Status__c = 'Approved';
        insert proj;
        
        Task__c tsk = new Task__c();
        tsk.Name = 'test';
        tsk.Start_Date__c = system.today()+2;
        tsk.Due_Date__c= system.today()+5;
        tsk.Status__c = 'Open';
        tsk.Project__c = proj.id;
        tsk.Project_Status_Approved__c = true;
        tsk.Email_Sent_Flag__c = true;
       
        insert tsk;
        System.assert(tsk.Id != null);
        
         
        tsk.Task_Executioner__c = strContactId.id;
        tsk.Task_Executioner_1__c = strContactId.id; 
        tsk.Task_Executioner_2__c = strContactId.id;
        update tsk;
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage ();
        mail.setTargetObjectId(tsk.Task_Executioner__c);
         
   }


Thanks !!