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
Daniel GageDaniel Gage 

Can't deploy *anything* from Sandbox to Live

I have a serious problem that I cannot figure out. I am new to Salesforce so bear with me.
In the Sandbox, every single Class and Trigger is above 75 percent. Total coverage in Sandbox is 88 percent.
In production Total coverage is 86 percent.

I am unable to deploy *anything* from the sandbox to Production. (this includes a completely empty class).
When trying to deploy to production, all it says is ", Details: Average Test coverage across all Apex Classes and Triggers is 56%, at least 75% test coverage required".

I have absolutely no idea what this means because Sandbox is at 88 percent and Production is at 86 percent when looking at the Developers Console.

Please help. I need whatever ideas one can give. And as I said, it's not releated to any specific thing in what I am deploying. I can't deploy an empty class...

Is there a way to remove some of the Apex Tests within Production? (Because I certainly can't add any... I've been trying to add updated test classes with higher coverage in the Sandbox)

Best Answer chosen by Daniel Gage
Daniel GageDaniel Gage

So.. there was a problem class in the Production server that seems to be causing all of this. (from what SF Support says).

 

I'll be opening up another thread to discuss that one. Thanks to everyone for their input and help.

All Answers

PratikPratik (Salesforce Developers) 
Hi Daniel,

When you deploy any metadata from Sandbox to Production, Salesforce will do Test coverage check before deploying the metadata. You can check the Test coverage for production once again and if it's above 75% then just try to deploy a simple custom field from Sandbox and then try to deploy the classes.

Thanks,
Pratik
Daniel GageDaniel Gage

Pratik,
First, thank you for your time.

That's the part that's driving me crazy. In Production, it says that it is 86 percent. (I have cleared the tests and retested in the Development Console, to try and rule anything out).
I tried sending over just 1 new custom field (as suggested) and got the same error. I've tried sending over empty classes as well. Same error.

I've tried sending over updated versions of some of the test classes, which increase coverage. Same error. I've gone into the developer console, cleared all the test data, (in both Production and Sandbox).. and rerun all the tests... Coverage is at 86 percent in Production, 88 percent in Sandbox.
and it won't allow us to deploy anything. I have been working on this for over a week. I am at my wits end. I NEED something that will tell me what is happening. Because this doesn't make any sense to me.

Daniel GageDaniel Gage
Apparently something I did in Development dropped my coverage there to 86 percent. But it still doesn't make any sense

Sandbox
User-added image
Production
User-added image
When trying to deploy anything at all
User-added image
PratikPratik (Salesforce Developers) 

Hi Daniel,

Will you please try to "Run All Test" in Sandbox and Production and then check the code coverage. (Clear Test Data before "Run All Test"). You can do it from Salesforce instance itself rather than Developer console.
I tried this on my org and I didi notice the difference in % of test coverage because of custom development.

The above mentioned issue is mainly because of Code Coverage so lets give it a try once again.  Go to Apex Class and Click on "Run All Test" .

Thanks,
Pratik
Daniel GageDaniel Gage

Pratik,

I had done that twice tonight(because I'm desperate). But when someone is willing to help, I do as asked. I have run them all again, and the same results Both Production and Live are at 86 percent. 

That being said. There are two Classes in Production that are sub 75 percent. 1 is 0 and 1 is 70. Both of these are ones that I have new test classes for, and have updated them in Sandbox to be 100 percent and 90 percent coverage respectfully. But it won't let me deploy them. Could these be the problem? If so, how do I get rid of them? Or over write them?

Could there be a problem with some managed classes/triggers? That have been installed. I noticed that many of them are failing the tests.

PratikPratik (Salesforce Developers) 
Hi Daniel,

No, managed package will cause any problem. As long as Total test coverage is above 75%, individual class' test coverage will not affect.

Have you tried "Clear Test Data" on clickin "View Test History" on Apex Test execution and then "Run All Test".
When I tried I did notice change in Test coverage (Clear Test Data helped, do it from Salesforce instance and not through Developer console)


Thanks,
Pratik
Daniel GageDaniel Gage

Pratik, 

Yes. In every instance I have tried to run all tests.. I have cleared the test data first. Both in Sandbox and in Production. Do you think it's possible there is something wrong with the MetaData? Should we, at this point, contact Salesforce Support? 

I tried to do it from the instance, as suggested here. But it still opened up the Developer Console. I have also run the Apex Test Execution on all tests, and none of them failed at all. 

PratikPratik (Salesforce Developers) 
Hi Daniel,

Yes, you can contact. Do post if you need any help.

Thanks,
Pratik
Daniel GageDaniel Gage
Thanks. Wish it had been something simple, but I've been banging my head against this for over a week.
lakslaks
Hi Daniel,

I do not know if this would be of any help in your scenario. Just posting in case if it is of any help.

I had faced an annoying situation related to code coverage not being met while trying to deploy to production sometime before. 

The reason was a whole host of validation errors that were being thrown due to incorrect format of data that were used in the test classes already in Production, hence reducing the overall code coverage.
After working on it for quite sometime it turned out that the guys who had done deployment previously had written the validation rules in such a way as to bypass the Profile that they were using to Login to the Production org for Deployment.

So when I was trying using the Profile I was assigned, it all failed. Whereas when I tried the same with that Profile after figuring out the problem, the code coverage was fine and I could move in the components.

A very inappropriate thing to do on the part of whoever deployed earlier, which took quite some time to figure out, since it wasn't exactly the problem with any of the classes which is what we spend time on when faced with such situations.

I guess this is not related to the problem you are facing since you are getting 86% code coverage in Production. But still just posted since you seemed to be at a dead  end of sorts. 

Regards,
Lakshmi.


Daniel GageDaniel Gage

So.. there was a problem class in the Production server that seems to be causing all of this. (from what SF Support says).

 

I'll be opening up another thread to discuss that one. Thanks to everyone for their input and help.

This was selected as the best answer
David Roberts 4David Roberts 4
I have the same issue!
79% in my production.
100% in my sandbox.
Cleared history till I'm blue in the face.
Can't see what to do.
How do I figure out what in the production is causing this. They are all 'managed' classes from packages we've installed such a 'duplicate check'.
I'm now seriously behind in implementing my own VF Query page.
Help!!!!