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

Hi, I am asalesforce admin trying to move a change set into prod. I am stuck with a trigger with 0 % coverage.

Hi All, I am a salesforce admin trying to move this trigger with 0 % code coverage into prod. I understand the code but not sure how to write a test class. Help !!!!!

trigger UpdateContactInfo on soship__c (before insert) {
soship__c[] shipments =;    
Set<String> orderNumbers = new Set<String>();    
Map<Id,sohdr__c> orders = null;   
sohdr__c order = null;

for(soship__c ship : ){
     System.debug('order number '+ship.soship_order__c);    
  orders = new Map<Id,sohdr__c>(           
 [Select Id, sohdr_order__c,  sohdr_contact__c, sohdr_conemail__c,sohdr_conphone__c ,sohdr_conmethod__c                  
             from sohdr__c where Id in :orderNumbers]);
    for(soship__c shipment:shipments){      
        order = orders.get(shipment.soship_order__c);
      if(order != null  ) {                                    
      shipment.soship_contact__c = order.sohdr_contact__c;               
      shipment.soship_email__c = order.sohdr_conemail__c;            
      shipment.soship_phone__c = order.sohdr_conphone__c;          
      shipment.soship_conmethod__c = order.sohdr_conmethod__c;                    
         system.debug(' order is null' );                 

} }
Marcilio SouzaMarcilio Souza

I guess it's something like this:
private class TestUpdateContactInfo {
    soship__c test = new soship__c();
   soship__c.Name = 'Teste';
// put here another required fields from the soship__c object
 insert test;


You just need a class test thar execute a insert in the object.

Best regrets,