Setup and teardown test cases

The following includes information about how to use setup and teardown test cases.

Setup test cases


Setup test cases are designed to run at the beginning of your test case in order to declare and define conditions and variables. The primary benefit of using a setup test case is to simplify the process of making global changes to test case parameters. 

Note: If you have several test cases arranged in a test folder, the setup test case will always execute first.

How to create a setup test case


Step 1: Click the New Test button in the top left portion of your screen.

Step 2: Select Setup Test Case.

Step 3: Choose the option to create a connection. If you need to create a connection, choose the preferred option or select No Connection Required.

Step 4: In the following example, create a test case for an Account Object

Step 5: Create a setup test case VariableDeclaration-Accounts.setup and specify the variables for all account test cases. For example, AccountName=”TestAcc001″. Once you add variables in the setup test case, make sure to change the Value Scope of the variable as Test Folder/Test Run if you want to use variables in test cases within the same folder of the setup test case. 

Step 6: Change the Value Scope to Test Folder/Test Run.

Step 7: Execute the account folder by selecting the folder and clicking Run

In this scenario, the VariableDeclaration-Accounts.setup test is executed first and subsequent tests leverage the variables defined in the setup test case. 

Teardown test case


A teardown test case will execute at the end of your test run within a test folder. Teardown test cases are used to perform post test execution actions. For example, a teardown test case can be used to delete test data generated during test execution.

The following includes instructions for creating a teardown test case. 

Step 1: Click on the New Test button within the top left portion of your screen.

Step 2: Select Teardown Test Case

Step 3: Choose the option to create a connection. If you need a connection, choose the preferred option or select No Connection Required.

In the following example, a teardown test case is created to delete test data that was created during test execution. 

Step 4: Create a test case Account Test Data Cleanup.teardown. 

Step 5: Add a SOQL step to specify the Object Id with the Account Name created in the setup test case. 

Step 6: Add a step to delete the record. You can reference the API testing support article to learn more. 

Step 7: Execute the Account folder. You will see that the VariableDeclaration-Accounts.setup test is executed first and that the teardown test case is executed at the end. 

Documentation library

Other available resources

Looking for something different?

We use cookies to better understand how our website is used so we can tailor content for you. For more information about the different cookies we use please take a look at our Privacy Policy.