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
Ryan GreeneRyan Greene 

100% code coverage in development but 0% in change set

Hello All,
I wrote a simple Trigger to not allow deletion of a specific record. Also, I wrote a Test Class with 100% code coverage in dev. When attempting change set I am receiving a Code Coverage Failure, with 0% code coverage. What is happening? I have tried the Change Set as both Default, and only run the Test related to my Trigger. I am deploying both in the same Change Set. All suggestions appreciated!
Thanks, Ryan
trigger callapplyTrigger on Lead (before update, before insert,before delete){
        for (Lead l : [SELECT Id,Email FROM Lead WHERE Email = '' AND Id IN :Trigger.old]){
                'Cannot delete this Lead.');
Test Class:
public class Test_callApply {
    @isTest static void TestDelete(){
        Lead lead = new Lead(Segment__c='Small Group',Email='',
        insert lead;
        Database.DeleteResult result = Database.delete(lead,false);

        System.assert(result.getErrors().size() > 0);
        System.assertEquals('Cannot delete this Lead.',result.getErrors()[0].getMessage());


Hi Ryan,

Can you try removing system.assert() and then validate the changeset. 



Mounica M 10Mounica M 10


I kind off faced the same problem.  

you should not run it in default try the Run Specified Tests and give the name of your test class in the the box.

this solved my issue


Ryan GreeneRyan Greene
Hey guys, I did Run Specified Tests of just the Test for my Trigger, which was in the same Change Set. The Change set only contains the Trigger and Test.
I also removed all three System.assert() and I still get Code Coverage Error, 0% code coverage.
I've deployed a lot of code and a lot Test code in the past and have never run into this issue! 
Hi Ryan,

I ran the same problem sometime back and found there was some internal error from salesforce side. I tried running the specific test after 24 hours and the same changeset worked for me. 

v varaprasadv varaprasad
Hi Ryan,

In your target org if you have following record [SELECT Id, Email FROM Lead WHERE Email = '' AND Id IN :Trigger.old

Means email like
If you don't have that email you trigger will not run I think.

Hope this helps you!

@For Support: