You need to sign in to do that
Don't have an account?
Sidharth
Doubt regarding code coverage
When I click “Calculate your organization code coverage” under Setup/Apex Classes it shows me 76%, and when I click “Run All Tests” it shows 77%. (in sandbox)
But still when I try to upload the class to production, it fails and displays “Average test coverage across all Apex Classes and Triggers is 74%, at least 75% test coverage is required.”
Does each class needs to be 75% covered or overall code coverage should match 75%?
Thanks
Sid
Please verify the code coverage which you have in the test class.
1. If you are quering the data?
2. Which may not have proper data in "PROD",it will results in less code coverage in PROD, so create the dummy data in test class and try uploading it to PROD.
3. Try to validate the else blocks & Catch blocks, which will result you to increase the code coverage.
4. Finally make sure each and every class should have minimum of 75% code coverage
If still your code is not covered then post here, Will try to figure it out to fix.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
All Answers
Not sure about this but "Calculate your organization's code coverage" provides the code coverage only for your organization's classes and not include the packaged classes. Run All does it all.
Best practice says each class should have code coverage 100%. Now when you create package then you must take care that classes you are including in package should have code coverage more than 75%. Lets say I have 10 classes which in combine covering 80% of code coverage.
Now I am including the test classes which are covering only 70% code coverage in my package. Then it will give me error. So you need to cover 75% of code coverage with classes which you are packaging.
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Thanks for your reply.
Though i am importing only 1 class, which has 100% code coverage, along with 3 custom fields. Still its giving me an error.
Please verify the code coverage which you have in the test class.
1. If you are quering the data?
2. Which may not have proper data in "PROD",it will results in less code coverage in PROD, so create the dummy data in test class and try uploading it to PROD.
3. Try to validate the else blocks & Catch blocks, which will result you to increase the code coverage.
4. Finally make sure each and every class should have minimum of 75% code coverage
If still your code is not covered then post here, Will try to figure it out to fix.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
Thanks a lot. It solved my problem
Solution: I was missing enough sample data in my Production.
Thanks
Sid
Hi
My overall code coverage is 80%. But when i am trying to create managed package it says code coverage is 70%.
There is no data in the org in which i am trying to create package, and it is showing 80% when run all test.
Kindly tell what could be the issue.
Thanks
Varsha