Run Relevant Tests Annotations in Spring '26
This explains how new @isTest annotation parameters in Salesforce’s Spring '26 release help control test execution during deployments. It covers using @IsTest(critical=true) to always run specific essential tests and @IsTest(testFor='...') to include tests for dynamically referenced classes. The post uses example Apex classes to demonstrate improving test relevance, especially when dependencies are dynamic. Salesforce teams can leverage these options to ensure critical and otherwise missed tests run reliably, reducing deployment risk related to validation rules or dynamic class usage.
- Use @IsTest(critical=true) to always run essential tests during deployments.
- Apply @IsTest(testFor='ApexClass:ClassName') to include tests for dynamically instantiated classes.
- Critical tests run regardless of what changes are deployed when using RunRelevantTests.
- Listing all classes/triggers in testFor improves clarity and maintenance.
- RunRelevantTests option must still be used during deployments to activate this behavior.
Image created by ChatGPT5.2 based on a prompt by Bob Buzzard Introduction In my first post on this new functionality I did a bit of digging into which tests are chosen when code is changed. If leaving it up to Salesforce doesn't quite cut it, there's the option to influence things via the two new parameters for the @isTest annotation. As in the first post, I've got a small set of classes with dependencies that are sometimes static and sometimes dynamic. As a refresher the key classes are: OpportunityUtils The protagonist in my little drama is a class named This implements an interface ( OpportunityUtilsIF ) with a single method, getBigDeals() , which receives a collection of opportunities and returns a new collection containing just those opportunities with a value greater than or equal to 250,000. There is a dedicated test class ( OpportunityUtilsTest ) which directly instantiates the class and executes a zero/one test.