To verify the functionality of your Apex code, Gearset allows you to run your Salesforce unit tests when you deploy changes to your orgs. There are four different test levels you can choose from.

Test levels

  • Default: In a sandbox, no tests are executed. In production, all local tests are executed if your deployment package contains Apex classes or triggers. Local tests are all tests, except those that originate from managed packages. If your deployment package does not contain Apex components, no tests are run.
  • Don't run any tests: No tests are executed, unless you are deploying to production and your deployment package contains Apex classes or triggers, in which case the default tests are run.
  • Run only your tests: All tests in your organisation are run, except those that originate from managed packages.
  • Specify tests to run: Only the tests that you specify are run. You must specify names of test classes in a comma-separated list. Code coverage requirements differ from the default coverage requirements when using this level in production. The executed tests must cover the class(es) or trigger(s) in your deployment package with a minimum of 75% code coverage. This coverage is computed for each class or trigger individually and is different from the overall coverage percentage.

Specifying the test level in Gearset

  • Validations: To run the default test level, click the main "Validate deployment" button on the pre-deployment summary. To specify the other test levels, click the arrow to the right of the button and choose the test level for the validation.
  • Deployments: To run the default test level, click the main "Deploy now" button on the pre-deployment summary. To specify the other test levels, click the arrow to the right of the button and choose the test level for the validation.
  • Continuous integration: You can set the test level when creating or editing a CI job in the "General settings" tab. If you make changes to the test level of an existing job, they will be applied the next time the job runs.

For more information on Apex testing, see the Salesforce Trailhead module on testing: https://trailhead.salesforce.com/en/modules/apex_testing/units/apex_testing_intro

Did this answer your question?