+ Start a Discussion
Ivan Liu (CCE)Ivan Liu (CCE) 

How to deploy code change if code coverage is lower than 75% on production site?

Previously I have written some code on a trial site. Unfortunately, the site became production before I had a chance to complete the test code. Now I continue to develop the code on a sandbox but it can't be deployed back to the production site since it keeps saying the code coverage on the production site is lower than 75%. How can I get this fixed and deploy the code?
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
Hi Ivan,
Unfortunatly salesforce doesnt allow you to deploy your code if code coverage is lee than 75%. You must write test method to ensure coverage is atleast 75%.

Thanks,
N.J
Ivan Liu (CCE)Ivan Liu (CCE)
Hi N.J.
My new code on the sandbox is well covered by tests, over 80%. But the problem is that I have some old code on the production site too with little test coverage. What I want to do is to replace the old code with the new from Sandbox. But the production site prohibits the deployment from the sandbox, saying that my old code has insufficient code coverage. Or I can add test code manually to the production site, but it doesn't show me any "New" or "Edit" links.
 
Chris ShadeChris Shade
Ivan,

I'd back up your code somewhere else.  Refresh your sandbox with your production instance then work on getting the 75%+ coverage in the sandbox.  If you do this then you should be able to deploy it in your production instance.

Chris
Ivan Liu (CCE)Ivan Liu (CCE)
Hi Chris,

I've done the way as you said. I still got the same message that stopped me from deploying for the reason of insufficient coverage. Currently, my production instance has a coverage of 6% but the sandbox has 82%. Yet, the sandbox code still can't be deployed in the production instance.

Ivan
Nilesh Jagtap (NJ)Nilesh Jagtap (NJ)
The obvious reason I see here is, there might be some configuration changes on production which are causing test failures and giving lesser code coverage as compared to your sandbox instance. If this is not the case, you'd like to file support case with salesforce.


Thanks,
N.J
Chris ShadeChris Shade
I think that if you refreshed your sandbox then the configurations should match.  I don't know why there would be variation in the coverage.