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
WikWik 

Test Class

Hi,

How do goo about writing Test Class for this piece of Trigger?

trigger updateopps on Quote(after insert, after update)
{             
     Map<Id,Opportunity> miMap = new Map<Id,Opportunity>();
     Set<id> Ids = new Set<id>();
         for (Quote  mir : Trigger.new)
         {
             Ids.add(mir.OpportunityId);
         }
    
     Map<id,Opportunity> miMap2 = new Map<id,Opportunity>([Select Id, Project_Engineer_1__c,Project_Engineer_2__c from Opportunity Where Id in :Ids]); 

         for (Quote mir : Trigger.new)
         {
         if(mir.Primary__c){
             Opportunity mi = miMap2.get(mir.OpportunityId);
             mi.Project_Engineer_1__c = mir.Project_Engineer_1__c;
             mi.Project_Engineer_2__c = mir.Project_Engineer_2__c;
             miMap.put(mi.id,mi);
         }}
        
         if(!miMap.isEmpty())
         {
             update miMap.values();
         }
}
pradeep naredlapradeep naredla
Hi wik,

1) insert an opportunity record
2) retrive the same opportunityu record 
3) insert an quote record and assign the retrieved opportunity to the quote
4)now retrieve the quote oppoortunity and by satisfieng the condition just update it.

Thanks,
pradeep.