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

Code coverage across all Apex Classes and Triggers is 73%, at least 75% test coverage is required
Hi,
All My test classes average code coverage is 84%, But i am always getting Average test coverage across all Apex Classes and Triggers is 73%, at least 75% test coverage is required error while deploying into Production.
What Might be the Problem with this.
Thanks
Mahesh....
Usually this has to do with the data in test vs. production. It could be that there are parts of code that don't run because the data present in production doesn't fit the test conditions necessary for your unit tests. No silver bullet to solve this other than to walk through your unit tests and look for data dependencies (queries against existing data, specific records, user account runAs user stuff)
You should also look for any differences between test and production in terms of validation rules, workflow rules, etc. Sometimes for large deployments, I'll deploy my object changes (custom fields, etc) and workflow first...and then deploy code.
hope that helps
--Kevin
All Answers
Usually this has to do with the data in test vs. production. It could be that there are parts of code that don't run because the data present in production doesn't fit the test conditions necessary for your unit tests. No silver bullet to solve this other than to walk through your unit tests and look for data dependencies (queries against existing data, specific records, user account runAs user stuff)
You should also look for any differences between test and production in terms of validation rules, workflow rules, etc. Sometimes for large deployments, I'll deploy my object changes (custom fields, etc) and workflow first...and then deploy code.
hope that helps
--Kevin
Excellent insight Kevin - I was scratching my head about this one.
I am sure you are querying some records that exists in sandbox but not in production. The best way to solve this error is to insert some dummy records in testMethod then call the class.
Suppose if your code is:
Modify this code to:
I had come across the same in the past. Hope this helps.
Perfect Kevin....... Thanks for Your.........
mahi
Hi kevin_swiggum,
I am also facing this same issue. Can you explain me How the test class will depends on production data?
Hi Kevin
Thanks for this post.
can you explain me more briefly about this.because I also facing this problem i couldn't able to found out
In my test class I am not using organization data I created the data in my test class itself.then how it will get differ from
test to production
Thanks in advance