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
Dev87Dev87 

Trigger Apex Class before upfate

I want to create test class for this trigger: 
trigger TriggerApprovalCommentOpp on Opportunity (before update) {
if(trigger.isUpdate){
             List<Opportunity> opptyList =  [Select id,
                                                   (Select Id, 
                                                         IsPending, 
                                                         ProcessInstanceId, 
                                                         TargetObjectId, 
                                                         StepStatus, 
                                                         OriginalActorId, 
                                                         ActorId, 
                                                         RemindersSent, 
                                                         Comments, 
                                                         IsDeleted, 
                                                         CreatedDate, 
                                                         CreatedById, 
                                                         SystemModstamp 
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC) 
                                                    From opportunity
                                                WHERE Id IN : Trigger.new];

             if(opptyList.size() > 0){

               for(Opportunity opp : opptyList){
              
                for(Opportunity opp1 : Trigger.new) {
                  
                         //check copy comment is true
                         if(opp.id == opp1.id && opp1.CopierCommentaires__c) {
 
                           if (opp.ProcessSteps.size() > 0) {
                            
                         opp1.Drniercommentairedapprobation__c = opp.ProcessSteps[1].Comments;
                         opp1.CopierCommentaires__c = false;
                         
                
                           }
                           
                        }
                 
                    }
               }
             }   
        }  
}

Can you help me.
VamsiVamsi
Hi,

Create couple of opportunities and make sure that CopierCommentaires__c is FALSE and add process steps to only few opportunities and then update opp making CopierCommentaires__c to TRUE. Finally verify that CopierCommentaires__c  is False using system.assert.

Hope this helps...!!