-3

trigger

trigger cptmpaddtoperadd on Student__c (before insert,before update) 
{
     for(student__c s: Trigger.new)
        {
          if (s.Copy_temp_addr_to_perminant_address__c )
           {
           s.Perminant_address__c=s.Temp_address__c; //  getting not covered at this point

           } 
         }
}

test class :

@istest
public class testcopytmptoper 
{   
     static testmethod void copytmptoper()
    {
       Training__c t = new Training__c();
        t.Name = 'cptmptoper';
        insert t;
        Batch__c b = new Batch__c();
        b.Training__c = t.Id;
        insert b;
        student__c std = new student__c();
        std.Batch__c = b.Id;
        std.Name = 'krish';
       if(std.Copy_temp_addr_to_perminant_address__c == true)
        std.Temp_address__c = 'hyderabad';
         insert std;
          list<student__c> ss = [select id,Temp_address__c,Perminant_address__c from student__c where id =:std.Id];
           system.assertEquals(ss[0].Perminant_address__c,ss[0].Temp_address__c);
         }
}

can anyone help me with this ...!!! Thanks in advance.

Keith C
  • 135,775
  • 26
  • 201
  • 437
vamshi krishna
  • 31
  • 1
  • 12

1 Answers1

2

In Trigger, you are checking whether Copy_temp_addr_to_perminant_address__c is true, but in Test Class, this field is not set to true.
Please try updating this line if(std.Copy_temp_addr_to_perminant_address__c == true) in test class to std.Copy_temp_addr_to_perminant_address__c = true;

villsiva
  • 628
  • 8
  • 9