function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SamergSamerg 

code coverage 0% when deploying new inbound changeset

Hi,
I am deploying a new inbound changeset and I got an error that I have 0% coe coverage.
What does this mean? note that I am choosing default option.
is it running only the tests that are included in the inbound changeset? or all tests related to the changes I am deploying.
It's a bit confusing.

Thanks,
samerg
Best Answer chosen by Samerg
Danish HodaDanish Hoda
Hi Samerg,

Answer to the first query - If your changeset contains trigger A, Classes B and C, you need to create test classes for trigger A (atleast 1% code-coverage required), test classes for B and C (atleast 75% is required).
Answer to the second query - If the class is disabled, you need not to create test class.

All Answers

Andrew GAndrew G
Hi samerg

From Salesforce articles:

When a change set is deployed to a production org, all local Apex tests in that org are run by default if you’re deploying any Apex classes or triggers. If the target org is a sandbox, however, tests aren’t automatically run.

So, if you have chosen default, all tests are run, except the ones that originate from managed packages. If your package doesn’t contain Apex components, no tests are run.

Regards
Andrew
Danish HodaDanish Hoda
Hi Samerg,
If your changeset is containing Apex class/trigger, try deploying your it using the last option - Run specified tests and add the test class of your component (classes/triggers), if still it is giving 0% code coverage, it might be due to -- 

1. some settings that you used in Sandbox while creating testsetup data or running test sceanrio (test methods) is not the same in prod.
2. some previous class, alraedy present in prod, has been modified which is failing.

In any of the cases, you will get the list of reasons that is causing this error.
SamergSamerg
Hi Danish,
In the list of specific tests, I should put all the tests related to the classes and triggers in the changeset?

Thanks,
Samer
SamergSamerg
And If I am deploying a class that I have disabled, would I also need to create a test for this one?

samer
Danish HodaDanish Hoda
Hi Samerg,

Answer to the first query - If your changeset contains trigger A, Classes B and C, you need to create test classes for trigger A (atleast 1% code-coverage required), test classes for B and C (atleast 75% is required).
Answer to the second query - If the class is disabled, you need not to create test class.
This was selected as the best answer