When we deploy change sets that contain Apex classes such as controllers, we'll always deploy using default unit testing thus running all test classes. In my mind, this is best practise to ensure the change set and emulation of it running touches everything, and everything is validated.

However, when the change set only contains unit tests, is it bad practice to only run those unit tests to speed up their deployment given they're ran privately?

I haven't encountered nor read of any problems this could cause, but I'm curious.


Is it bad practice when deploying only unit tests to only run those unit tests during deployment?

1 Answer 1


If you're deploying to production, you'll have to run all tests anyways. If you're deploying to another sandbox, feel free to run just those tests.

See these notes:

Default Test Execution in Production

When no test level is specified in the deployment options, the default test execution behavior depends on the contents of your deployment package. When deploying to production, all tests, except those that originate from managed packages, are executed if your deployment package contains Apex classes or triggers. If your package doesn’t contain Apex components, no tests are run by default.

  • Even when we deploy to production, we have the option to: run all tests including managed packages, run all tests excluding managed packages, and run only specified tests. There is also an option for "Default" which is "All tests excluding managed packages". Do these options get ignored when deploying to production?
    – Dan Jones
    Commented Aug 25, 2016 at 11:56
  • @Poet see edit. When deploying apex, all tests are run. For other types, you can choose if you want to.
    – sfdcfox
    Commented Aug 25, 2016 at 12:03
  • 1
    @sfdcfox I am not sure about "all tests" part when deploying to production. If you choose run spesified tests when deploying to production, you just need to specify exact tests to cover your to-be-deployed apex components tests and this tests should get 75% code coverage for each to-be-deployed apex component not total 75% coverage.
    – tugce
    Commented Aug 25, 2016 at 13:12

You must log in to answer this question.

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