You need to sign in to do that
Don't have an account?

Apex Code Coverage issue
Hello
I have 95% covergae in production , and I moving classes/triggers that have (97%) coverage in dev.
Whan I deploy in production , I am getting the error
Code Coverage Failure
Your organization's code coverage is 73%. You need at least 75% coverage to complete this deployment.
what am I missing here !?
Thanks
I have 95% covergae in production , and I moving classes/triggers that have (97%) coverage in dev.
Whan I deploy in production , I am getting the error
Code Coverage Failure
Your organization's code coverage is 73%. You need at least 75% coverage to complete this deployment.
what am I missing here !?
Thanks
Have you checked the coverage on all your triggers in your production org? I pushed a trigger to prod a few months back that did not have the required coverage and it was allowed in. That surprised me so I started googling and found this blog by Jeff Douglas http://blog.jeffdouglas.com/2009/03/04/how-to-deploy-apex-without-test-coverage/ (http://blog.jeffdouglas.com/2009/03/04/how-to-deploy-apex-without-test-coverage/)
It seems that coverage can be viewed as an average across all your triggers. So even it that trigger has 95% coverage it could be possible that the new code was enough to lower your overall average based on all your triggers coverage.
All Answers
Just try to touch each aspect while writing in each scenario of functionality. after that error remain the same then use fake test coverage(i++) to complete the code coverage. hope that make sense.
-
The code between your sandbox and production is out out of date. You have more code in production than in sandbox, perhaps.
-
Your unit tests were written to use existing data, either using a really old api version that tended to rely on existing data, or by setting the SeeAllData=true annotation. Data between sandbox and production is likely different, and if your tests rely on existing data, then your code and test code would behave differently.
See the following doc (or do a quick google search) for more information: http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_testing_intro.htmActually I am using SeeAllData=true annotation , but this wasnt an issue and I was able to move my code before, I need to to See AllData because in my test I am creating a record in an object and there are some lookup fields need to be filled,. and the values I am selecting in TEST I am sure they are existing in PROD , for example ( Urgency = LOW,HIGH,MEDIUM) thats a lookup table and has same values in all environments.
Sameer what is "fake test coverage(i++)" and how can I use this ?
Thanks
How did you arrive at 95% code coverage in Production? Is that what the system is telling you or did you calculate that? Remember that during deployment ALL of your classes are tested.
Have you run all test in production prior to deployment to make sure everything is OK?
There are time when we are running out of time and deployment is urgent and code coverage is not upto the standard(75% and above).
then we can use this stretegy. it is not a good practice however it can allow you to cover the code-coverage.
for this we need to create a method in the code and call that method from test class. which almost cover the code coverage.
here i have an example fake method
We need to make sure that each increment statement must be in new line.
hope this resolve the query.
Have you checked the coverage on all your triggers in your production org? I pushed a trigger to prod a few months back that did not have the required coverage and it was allowed in. That surprised me so I started googling and found this blog by Jeff Douglas http://blog.jeffdouglas.com/2009/03/04/how-to-deploy-apex-without-test-coverage/ (http://blog.jeffdouglas.com/2009/03/04/how-to-deploy-apex-without-test-coverage/)
It seems that coverage can be viewed as an average across all your triggers. So even it that trigger has 95% coverage it could be possible that the new code was enough to lower your overall average based on all your triggers coverage.
Method does not exist or incorrect signature: [EmailManager].sendEMail(String, String, String)