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
Irish@accIrish@acc 

test class required

trigger updateDev_Lead on Project__c(after update) { 

          for(project__c prj: trigger.new)     {

 

    if(trigger.oldmap.get(prj.Id).Dev_Lead_User__c!=trigger.newmap.get(prj.Id).Dev_Lead_User__c) { 

   List<Quality_of_Delivery__c> Lstqod=new List<Quality_of_Delivery__c>();

    Lstqod=[Select project__c,Name,Dev_lead__c from Quality_of_Delivery__c where project__c=: prj.Id];         List<Quality_of_Delivery__c> qodToupdate=new List<Quality_of_Delivery__c>();

 

    for(Quality_of_Delivery__c thisqod: Lstqod)         {

                            {      

               thisqod.Dev_lead__c=prj.Dev_Lead_User__c;   

                

                    qodToupdate.add(thisqod);    

             }

        }

    if(!qodToupdate.isempty()){

           update qodToupdate;  

      }  

     }   

        }

}

PremanathPremanath

@sTest

class projecttest{

static testmethod void methodname(){

  Project__c p=new Project__c();

  p.name='Test';

  insert p;

 

  p.Dev_Lead_User__c=userinfo.getUSerId();

  update p;

 

  Quality_of_Delivery__c q=new Quality_of_Delivery__c();

  q.name='Test child';

  q.project__c=p.id;

  insert q;

 

}

}

 

 

 

 

prem

Irish@accIrish@acc
thanks for the reply
Irish@accIrish@acc
this is not coverig the whole code part...
Vinit_KumarVinit_Kumar

Irish,

 

Try below code :-

 

@IsTest(SeeAllData=true)
public class updateDev_Lead_Test{
static testmethod void MyUnitTest(){

User u1=[select id from User where name='<Some user in your org>'];

User u2=[select id from User where name='<Some other user in your org>'];

Project__c pr = new Project__c(Name='Test Project',Dev_Lead_User__c=u1.id,<----->);//Populate all the mandatory field to insert Project record
insert pr;

pr.Dev_Lead_User__c=u2.id;
update pr;

}
}