You are using an older browser that might negatively affect how this site is displayed. Please update to a modern browser to have a better experience. Sorry for the inconvenience!

Test Suites in Salesforce


By: Radha

What is Test Suite? 

Running specific set of test classes is a complex one and it’s hard to run them one by one. Salesforce has come up with new feature called Test Suite. Test Suite acts as container, and using this feature you can add a set of test classes and run them together. You can add up to a maximum of 200 test classes per TestSuite.

Availability? 

From the beginning of Spring 16 release orgs.

This feature is accessible via “Developer Console” in both Salesforce Classic and Lightning Experience.

How to Create New Suite? 

Step 1: 

Go to Developer Console > Select Test > New Suite.

Image

Step 2:  

Enter a name for your test suite and click OK.

Image

Step 3: 

Select and add the list of classes you are going to frequently run and click Save.

Image

What is New Suite Run? 

New Suite Run allows you to run TestSuites (Which contain list of classes).

Step 1: 

To run one or more TestSuite,  go to Developer Console > Select Test > New Suite Run.

Image

Step 2: 

Select the Test Suites from the Available Test Suites, and then select and Run Suites.

Image

Specify Run Parameters: 

You can specify run parameter on Settings before running the test Suites.  This functionality allows you to stop your test run from executing new tests after a given number of tests fail. You can set the failure threshold to an integer value from 0 to 1,000,000. This integer value sets the maximum number allowable test failures. A value of 0 causes the test run to stop if any failure occurs. A value of 1 causes the test run to stop after the second failure, and so on.

Image

How to use Suite Manager? 

Suite Manager allows you to do the following,

  1. Create a New Suite.
  1. Edit a Suite. (Adding and removing Classes).
  1. Delete a Suite.

To navigate to Suite Manager, go the Developer Console [Symbol] Select Test > Suite Manager.

Image

Here is the suite manager view.

Image

How to query list of Test Suites and Test Suite Members? 

ApexTestSuite: To know the list of available Test Suites.

Select Id, Name FROM ApexTestSuite

TestSuiteMembership: Represents a class in an ApexTestSuite.

SELECT Id FROM TestSuiteMembership WHERE ApexTestSuiteId = ’05FD00000004CDBMA2′

Reference: 

https://releasenotes.docs.salesforce.com/en-us/spring16/release-notes/rn_apex_tests.htm