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
NANCY1NANCY1 

Urgent: Even with 100% code coverage, Trigger is not getting deployed

Hi All,

 

I have the following trigger

 

trigger upsertmanagername on RMG_Employee_Allocation__c (after update)
{
   List<RMG_Employee_Master__c> opps = new List<RMG_Employee_Master__c>();
   List<ID> masterIds = new List<ID>();
   Map<ID, String> childDetailMap = new Map<ID, String>();
  
   for(RMG_Employee_Allocation__c c: Trigger.new)
    {
      masterIds.add(c.RMG_Employee_Code__c);
      childDetailMap.put(c.RMG_Employee_Code__c, (c.Manager_Name__c));
    }
 
   opps = [select id, Current_Manager__c from RMG_Employee_Master__c where id in :masterIds];
  
   for(RMG_Employee_Master__c rem: opps)
    {
      rem.Current_Manager__c = childDetailMap.get(rem.id);
      Update rem;
    }
  
   if(opps.size() > 0)
      Update opps;
}

 

 

And i have the following Apex Test class that has 100 % code covered in sandbox. But when i try deploying it to production i get an error: "Code coverage is 0% atleast 1% code coverage is required"

 

@isTest
private class Testupsertmanagername
{

   static testMethod void testTrigger()
   {
   RMG_Employee_Master__c rmg = new RMG_Employee_Master__c(Name='Test');
      insert rmg;
     
      RMG_Employee_Allocation__c rmgallo = new RMG_Employee_Allocation__c(
                                     Name='Test', Manager_Name__c='Unit Test',
                                     RMG_Employee_Code__c=rmg.id);
      insert rmgallo;
      update rmgallo;
     
      RMG_Employee_Master__c newrmg=[select Name, Current_Manager__c from RMG_Employee_Master__c where id = :rmgallo.id];
      System.assertEquals('Unit Test', newrmg.Current_Manager__c);
      }
      }

 

 

Please help

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

A few obvious things to check:

 

(1) Are you deploying the trigger and the test class together?

(2) Is the "code coverage is 0%" definitely associated with the trigger you are deploying?

(3) Are you getting any errors/exceptions when the unit tests are executed?

All Answers

bob_buzzardbob_buzzard

A few obvious things to check:

 

(1) Are you deploying the trigger and the test class together?

(2) Is the "code coverage is 0%" definitely associated with the trigger you are deploying?

(3) Are you getting any errors/exceptions when the unit tests are executed?

This was selected as the best answer
NANCY1NANCY1

absolutely i  was not deploying the trigger and the test class together...    :)

 

rathore_1987rathore_1987

Dear I think u are making mistake in deployment are u sending both trigger and test class in same package, same  problem I was facing before some days so try to deploy both in the same package I mean add both in same package n the deploy it in production environment.

 

Regards,

 

Rathore Kuldeep

SteveBowerSteveBower

Hey NANCY, if you're posting the same question in multiple posts, and you receive an answer that works in one posting, please cancel or update the other posting so that other folks (like me) don't waste time answering something you've already dealt with.   -Steve.

NANCY1NANCY1

Hi Steve,

 

I shall keep your suggestion in mind.... Thanks