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
dcgb2332dcgb2332 

Code Coverage not showing in production

I've created a custom object with related custom fields. I've also created an Apex Trigger to roll up data into said custom object. We tested it in production and we have 95% coverage. When I go to validate through the inbound change set, it says I have 0% coverage. How can this be? I've checked in both the developer console test and in classes (an apex class was created as well). What am I doing wrong? I've looked at the other forums and can't find an answer. Thanks in advance
Best Answer chosen by dcgb2332
Waqar Hussain SFWaqar Hussain SF
See below article which may help you. There are multiple causes of this issue. 
https://help.salesforce.com/articleView?id=000250168&language=en_US&type=1

All Answers

Raj VakatiRaj Vakati
  • Looking like you are not moving all the related code ( Classes and Triggers )  .
  • or your changes are in changeset like custom settings values 
  • Or Your trigger might be failing while deploying.. 
dcgb2332dcgb2332
I haven’t deployed yet, since the validation is failing. I am moving all related code (apex trigger, apex class, custom object, custom fields, custom permission sets.) All of them pass the validation. The only thing not passing is the code coverage. I’m not sure what you mean by or your changes are in changeset like custom settings values Thanks!
Raj VakatiRaj Vakati
Is there any other test classes are failing >>> What is the error message you are getting ?

Try to run specific test class .. 
dcgb2332dcgb2332
None of the test classes that I can see, are failing. Here’s what I’m transferring over (I’ve already deployed the custom object and custom fields, and they worked) [cid:image001.png@01D4018A.9124F520]
Raj VakatiRaj Vakati
Can u share the image pls .. 
dcgb2332dcgb2332
Sorry, I thought it uploaded
User-added image
Raj VakatiRaj Vakati
I need deployment error messages .. when you click on Deploy .. 
dcgb2332dcgb2332
Here is the error I receive

User-added image

And then it says: CustomObjectNameTriggerTesttestUpdateSystem.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Quote Status: bad value for restricted picklist field: Initiated: [Quote_Status__c] 
Stack Trace: Class.CustomObjectNameTriggerTest.testUpdate: line 15, column 1
Raj VakatiRaj Vakati
I found the issue ... Go to prod and add the Quote_Status__c picklist values form UAT .. Your production does not contain all the picklist values in Quote_Status__c .. 
Waqar Hussain SFWaqar Hussain SF
See below article which may help you. There are multiple causes of this issue. 
https://help.salesforce.com/articleView?id=000250168&language=en_US&type=1
This was selected as the best answer
dcgb2332dcgb2332
Waqar's answer was correct, I had to remove the "Restrict picklist to the values defined in the value set" selection, in my production envr. Thanks for your help!