Faster Apex Deployments with RunRelevantTests in Salesforce
RunRelevantTests is a new Beta Salesforce feature that accelerates Apex deployments by running only the tests relevant to your code changes instead of the entire test suite. It introduces a new test level to automate test selection, plus two new @IsTest annotation parameters to control test execution: critical=true to always run critical tests and testFor to link tests explicitly to specific Apex classes. This approach can drastically reduce deployment wait times in large orgs with thousands of tests. Salesforce teams can enable this in sandbox, properly annotate tests, and integrate RunRelevantTests into their CI/CD workflows for faster feedback loops.
- Use --test-level RunRelevantTests in CLI deploys to run only relevant Apex tests.
- Annotate foundational tests with @IsTest(critical=true) to always run them.
- Link test classes explicitly with @IsTest(testFor='ApexClass:MyClass') for precision.
- Test thoroughly in sandbox first since RunRelevantTests is currently Beta.
- Maintain 75% code coverage in production despite using RunRelevantTests.
Stop running your entire test suite on every deploy — let Salesforce figure out which tests actually matter ⚠️ Beta feature: RunRelevantTests is available as a Beta feature and is subject to the Salesforce Beta Services Terms. Not recommended for production deployments without thorough sandbox testing. If you've ever stared at a deployment progress bar while your entire 2,000-test suite runs because you changed one Apex utility method — this feature is for you. Introduces RunRelevantTests , a new test level that automatically analyzes your deployment and runs only the tests relevant to your code changes. What Is RunRelevantTests ? Before this update, Apex deployments offered four test levels: Test Level What it runs NoTestRun No tests (sandbox only) RunSpecifiedTests Only the tests you explicitly name RunLocalTests All tests in your org (excluding managed packages) RunAllTestsInOrg Every test including managed packages Adding a fifth option: RunRelevantTests .