1

Couldn't think of a good way to describe the issue in a short title, but here's the breakdown. I have a change set I'm trying to deploy from sandbox. The change set contains 2 classes and a VF page. When deploying I'm running a specified test class. This test class is giving between 80% and 90% coverage on the larger of the classes in the change set.

The other class in the change set is not being covered by that test class, however it's only 7 lines, so it should not be pulling the average down below 75% across the whole change set. When I try to deploy, I get this error:

Your code coverage is 0%. You need at least 75% coverage to complete this deployment.

With just the one (uncovered) class's name underneath. Far as I knew, the code coverage is looking for an average across classes, correct? Not each individual class? And note, this is a class, NOT a trigger. I am aware that triggers need at least 1%.

Why does the validation seem to only consider the one class's coverage? Is it because the second class already exists, and doesn't have major changes? I even tried including the test class in the change set to no avail.

The other really bizarre thing is that if I choose 'Default' for the tests to run for this change set it doesn't actually run any tests, which I find very strange...

  • Are you sure you're deploying into production? The default behavior for sandboxes is to not run tests, but if you tell it to run tests then it will fail the change set for coverage failure. – IllusiveBrian Nov 8 '17 at 16:19
2

From the release notes for Summer '15 and also doc, when you choose which Tests to Run in a Deployment the following rule applies

If the code coverage of an Apex component in the deployment is less than 75%, the deployment fails.

If you choose to deploy running only certain test-classes, it seems that they all, individually, cannot be under 75%.

  • Dang, that stinks...Ah well, not much I can do about it. Thanks for the info. – Dominator_101 Nov 8 '17 at 15:59
1

Far as I knew, the code coverage is looking for an average across classes, correct?

Incorrect. Change Sets looks for coverage in individual classes. This is the point where "Run Individual Tests" come in when validating and deploying change sets, so you can run the specific tests that cover your classes in your change set.

Why does the validation seem to only consider the one class's coverage?

Because change sets are designed that way. You need to have every class 75%+ covered.

The other really bizarre thing is that if I choose 'Default' for the tests to run for this change set it doesn't actually run any tests

Now that's weird, yes. It should run all the tests in your organization. It may seem a weird question but are you sure you have the test classes in your environment that is receiving the change sets? I'm asking because I've seen some cases of people deleting the test classes from production thinking they wouldn't need them anymore.

Also, you can try the "Run specified tests" option.

  • Yeah, there are test classes in the target org. There's a ton, actually, both managed and unmanaged, which is why I was running only specified tests. – Dominator_101 Nov 8 '17 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.