In this blog post, I will try my best to explain about Test suite and how you can create a test suite ? and also we will see how to deploy Test suite from one Salesforce org to other salesforce org.
Table of Contents
ToggleWhat is test suites in salesforce?
Test suite is a collection of apex test classes which you can run together. For instance, create a suite of tests that you run every time you prepare for a deployment or everytime Salesforce releases a new version. .You can set up a test suite in the Developer console where you can specify which set of test classes you want to execute regularly.
How to create test suites?
Step 1: Go to your developer console. Select “Test” tab ->click on New Suite from the dropdown.
.
Step 2: Provide the name for the test suite and click Ok .
Step 3: Now you can select the list of classes which you want to execute from available test classes and move to the selected test classes section as shown below:
You can use the arrow to move classes from one list to other.
How to run test suites?
To run test suite from the developer console, go to the Tab “test” and click on the New Test Suite run and select the test suite you want to execute and click “Run Suites ” button.
How to deploy Apex test Suite from one Salesforce org to another org?
Are you working on the same set of test classes and you are manually creating test suites individually in your dev, test and other environments? If yes, then you need to read this blog post carefully. If you have created a test suite in one of the salesforce org, you can migrate it to other environments using metadata migration tool. “ApexTestSuite” is the metadata name to migrate apex test suite.
Below is the sample package.xml script to migrate apex test suites.After you have retrieved apex test suites, metadata components will be stored with .testSuite suffix and files will be stored in the test suite folder.
<?xml version ="1.0" encoding= "UTF-8" ?> <package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>TestSute Name </members> <name> ApexTestSuite</name> </types> <version>38.0 </version> </package>
If you are deploying additional test classes along with the test suite, then you have to add new apex class to your package.xml.For example, as shown below:
<?xml version ="1.0" encoding= "UTF-8" ?> <package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>TestSuite Name </members> <name> ApexTestSuite</name> </types> <types> <members>ApexClass Name </members> <name> ApexClass</name> </types> <version>38.0 </version> </package>