I have updated a class in a sandbox and successfully tested it. However, when I try to deploy it to production I am getting errors of tests which are failing for other classes which this class has nothing to do with. The tests for those classes are failing, and I am then unable to deploy my class.

Is this normal ? Are all of my other classes required to have an 75% code coverage when I am deploying a new class ?

Thank you very much for your help.

3 Answers 3


As of Salesforce Deployment process documentation - ALL classes and triggers must compile successfully:

The deploy call completes successfully only if all of the following must be true:

  • At least 75% of your Apex code must be covered by unit tests
  • Every trigger must have some test coverage
  • All classes and triggers must compile successfully

Read this: Understanding deploy

This means that the total code coverage of all classes must be at least 75%. Some classes can have code coverage lower than 75% (10% for example), the total amount is important here.

  • The classes which I am having problems with are not running properly because apparently something has changed in the app which they belong. But one of them already has 81% code coverage and the other is an @test class. Can I just get rid of the test one ? If the other one has 81% code coverage then how is it failing when I try to deploy a different class unrelated to it ?
    – Zoom_v
    Apr 23, 2013 at 20:28

The application as a whole has to work & be somewhat stable. If some other class suddenly started to fail check if there's a relation between what you're doing and what this class is about. Maybe there's something indirect (via trigger for example)? Maybe somebody made a change on production that suddenly broke the functionality. A good example is a new validation rule or a new required / unique field.

Maybe your unit test relies on production data that changed in the meantime?

Check if the unit test of this "broken class" fails also when just run the test execution on production. If they fail you know something changed. if they pass - it's most likely something in your deployment that breaks them. Try to run it from Eclipse / Data Migration tool if possible, if not - just use web interface.

As mast0r said - you need total 75% or better across your whole codebase (classes and triggers). And of course no errors.

  • Thank you very much for your input. I really appreciate it.
    – Zoom_v
    Apr 22, 2013 at 19:16

So "No" when you ask "Are all of my other classes required to have a 75% code coverage..." There is a difference between that and ALL of your classes having 75% coverage. This means in aggregate.

It is common for something to have changed resulting in a change to your code coverage so you do need to troubleshoot as suggested above and change as needed.

  • One of the classes which are preventing me from deploying a change set has 80% code coverage. Also, when I do a Run Test within the class it runs successfully. What could be happening here ?
    – Zoom_v
    Apr 24, 2013 at 13:50
  • Because your production is running ALL tests again and something that previously worked is now failing. Run your tests in Production and see which one of those classes has low coverage. You will then need to change that class, or multiple, in your Sandbox and deploy those. As was stated above, sometimes a field or validation rule, etc. gets changed in Production which affects the test class coverage. It's most always something like that since the API versions are backward compatible.
    – ddeve
    Apr 24, 2013 at 17:19
  • If I have a class in Production which runs @Test but has 0% code coverage does that mean it is currently never being run in Production ? If so, could I just get rid of it without any side-effects ?
    – Zoom_v
    Apr 25, 2013 at 19:04
  • Are you sure that's not a test class? Test classes show as 0% since they are not tested. These do not count against your org as testing a test class is circular. If its a regular class, no way to answer your question since the class was there for some reason.
    – ddeve
    Apr 25, 2013 at 22:29
  • Yes, it was a test class. That's why I was wondering if I could get rid of it without and side-effects.
    – Zoom_v
    Apr 26, 2013 at 16:22

You must log in to answer this question.

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