You need to sign in to do that
Don't have an account?
asadim2
Strange Code Coverage error in deployment
The following 2 points should explain everything:
1. Code coverage in production is 74% (cleared all tests, then re-ran all to make sure). When deploying a single field (some dummy test field) from the sandbox we get this error:
Your code coverage is 63%. You need at least 75% coverage to complete this deployment.
2. Production is on Summer '15. Sandbox is not. Regardless, we hardly have multi-line code anywhere (maybe 1% of all Apex code).
Why is production code coverage falling to some obscure value during deployment of changesets?
1. Code coverage in production is 74% (cleared all tests, then re-ran all to make sure). When deploying a single field (some dummy test field) from the sandbox we get this error:
Your code coverage is 63%. You need at least 75% coverage to complete this deployment.
2. Production is on Summer '15. Sandbox is not. Regardless, we hardly have multi-line code anywhere (maybe 1% of all Apex code).
Why is production code coverage falling to some obscure value during deployment of changesets?
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments&language=en_US
I am now seeing 63% coverage in production (under Apex Classes > Estimate Code Coverage), although Developer Console is still showing 74%.
All Answers
Please keep in mind, that we are seeing 2 very different values for code coverage in the same org (production). I assume what's in the dev/sandbox org is irrelevant.
This is an old org, hence the seeAllData=true in the test cases.
https://help.salesforce.com/apex/HTViewSolution?urlname=Code-coverage-steps-and-considerations-prior-to-deployments&language=en_US
I am now seeing 63% coverage in production (under Apex Classes > Estimate Code Coverage), although Developer Console is still showing 74%.
(I know this is a really lame example, but it showcases what we want)
If you have a test that has seeAllData=true and you ran this in a dev org that had at least on Contact with that ContactType set, you'd get 100% coverage for this class. If you ran this with seeAllData=true in prod but had no Contact records with that contactType set, you'd get 20% coverage for this class.
I would recommend that you look at a class by class base for where your coverage percentages differ in Production vs your Sandbox and then compare the lines that differ and the tests that run. I would guess that one of your seeAllData tests is expecting data that exists in your Sandbox but does not exist in your Production instance.