0

If there are four classes in the sandbox and first three classes have 100% code coverage and fourth class 0% code Coverage. Will the deployment will be success or fail

2 Answers 2

2

Deployment to a Sandbox does not require code coverage; the deployment would succeed. For Production, though, it depends on the parameter testLevel. If testLevel is set to RunLocalTests, deployment would succeed. If testLevel is set to RunSpecifiedTests, then the deployment will fail. This is true for both IDE deployments and Change Set deployments.

0

As @sfdcfox stated this depends where you are deploying your classes to. Deployment will succeed if you have 75% overall code coverage.

To further answer your question, this depends on the amount of lines in class 1,2,3 and 4.

Consider the following example:

  • You have a new Salesforce org with no custom code in production.
  • You are deploying your 4 classes to production in the same package / changeset
  • Class 1,2 and 3 have a combined total of 100 lines of code
  • Class 4 has 200 lines of code.

Your overall code coverage is 100 / 300 ~ 33%. This will fail deployment.

Consider another example where

  • Class 4 now only contains 20 lines of code.

Your overall code coverage is now 100 / 120 ~ 83%. This exceeds the 75% threshold so deployment to production will succeed.

** you should note that this is bad practice. You should not deploy classes with no code coverage for obvious reasons.

Not to mention that at some point in time you will probably piss off the developer that succeeds you when he realizes he has to re-write unit tests for the classes that you developed.

Please refer to Code Coverage Best Practices for more information.

You must log in to answer this question.

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