5

When I try to deploy a change set, the validation step (and deploy) fails and I receive this error message:

Average test coverage across all Apex Classes and Triggers is x%, at least 75% test coverage is required.

I already encountered it, but I had additional error messages guiding me to know which class prevent deployment. In this case, I went in sandbox and looked at every Apex class included in the change set, executed all the tests and they are all at least over 80%.

Is there a way to see which class is blocking deployment?

3
  • 1
    This happens when some of the existing data in production causes the code to fail. Caan't you check the debug log while deploying there you will get exactly which class and method is failing? Nov 29, 2013 at 19:00
  • @ShebinMathew The debug log doesn't seem to display the values and we have many unit testing classes, so it does reach the limit.
    – jpmonette
    Nov 29, 2013 at 19:22
  • 1
    In this case deploy using eclipse in part by part strategy so that you can identify the problem more easily Nov 29, 2013 at 19:31

1 Answer 1

5

Unfortunately change sets are fairly limited in the information they provide about why a deployment fails. You don't get access to the deployment logs, and hence can't see what sort of code coverage you're getting.

If I have a deployment that fails like this I do the following

1. Run all tests in production.

You may have tests that are failing, commonly due to the addition of a new validation rule (among a million other reasons). If this is the case take steps to fix the test failures, such as turning off the offending validation rules, until you're able to get your code coverage up enough for you to deploy.

2. Run all tests in the source org

It's possible that you're deployment is causing test to fail. Running all tests in the source sandbox will let you know if that's the case. Once you fix the failures in the sandbox and confirm you've got enough code coverage build a new change set and redeploy.

3. Deploy with ANT / Eclipse / Maven's Mate

If you're still getting good test coverage on both sides you'll need to dig a little harder. If you deploy with ANT / Eclipse / Maven's Mate you'll get deployment logs which can give you some better insight into what's causing the low code coverage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .