0

I am the only developer in the new project and there are many classes that are not passing unit tests. I want to deploy only one class (which have only 10% of test coverage)

How could I deploy this? Could I deploy my class and only a few unit test classes (in order to pass 75% of unit test coverage)?

2 Answers 2

3

As mentioned in the documentation ,

You must have at least 75% of your Apex covered by unit tests to deploy your code to production environments.

While you run the specific test class of your trigger or apex class your deployment should cover at least 75% of the code. Here overall coverage won't come into the picture.

As per doc,

Default : All tests will be run with the default behaviour. All local tests are executed in production if any changes are made to Apex Classes, Apex Triggers, or Apex Flows that are part of the Salesforce package.In sandbox environment, no tests are executed. All tests, except those originating from managed packages, are local tests. In a package that does not contain Apex components, no tests are run.

Run Local Tests : When you select this option, all test classes in Salesforce are executed except for managed packages.

Run All Tests : When you select this option, all test classes in Salesforce are executed including all managed packages.

Run Specified Tests : Only the tests that the user specifies are executed. The user must create a list of all test classes in comma-separated form. The executed tests must cover the apex code coverage with a minimum of 75%. Each class or trigger is covered individually instead of the overall percentage.

Recommend reviewing this canonical-qa post

1

You can select the only test class that covers your class.

Select the last option when you deploy the changeset, then enter classes separaetd by comma without spaces.

enter image description here

You must log in to answer this question.

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