You need to sign in to do that
Don't have an account?
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:
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:
trigger callapplyTrigger on Lead (before update, before insert,before delete){ if(Trigger.isDelete){ for (Lead l : [SELECT Id,Email FROM Lead WHERE Email = 'testingtrigger1@test.com' AND Id IN :Trigger.old]){ Trigger.oldMap.get(l.Id).addError( 'Cannot delete this Lead.'); } } }Test Class:
@isTest public class Test_callApply { @isTest static void TestDelete(){ Lead lead = new Lead(Segment__c='Small Group',Email='testingtrigger1@test.com', FirstName='testRyan',LastName='testGreene',Status='New', Company='testCompany',City='Orlando',State='FL',LeadSource='Event'); insert lead; Test.startTest(); Database.DeleteResult result = Database.delete(lead,false); Test.stopTest(); System.assert(!result.isSuccess()); 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.
THanks,
Gaurav
Hello,
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
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!
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.
In your target org if you have following record [SELECT Id, Email FROM Lead WHERE Email = 'testingtrigger1@test.com' AND Id IN :Trigger.old
Means email like @testingtrigger1@test.com.
If you don't have that email you trigger will not run I think.
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com