Let’s assume there is test case which repeats the same step as another test. A complex test can be made up of several smaller tests or functionality. Further, if we are running a regression test suite then we might have several smaller tests which are created to test individual smaller functionalities. To test a complex functionality which is a combination of smaller functionalities, we can use either of two methods:
- We can record/code all steps for the complex functionality
- We can reuse other smaller functional tests as a step for complex test
How to Reuse a Test as Step for Another Test in Telerik Test Studio?
Test Studio allows users to use another test case as a step for a new test. Assume we are testing a web application. Each time we test it we will have to login to the application. So, for every test, if we record or code logging functionality then it will take extra effort. So, what we can do is, we can create a single login test and then we can use this test as a step for any new test we can create.
Create a Test
Let’s first create a Login Step for the application:
This logIn_test will act as the first step for the subsequent steps in the test. Let’s say our test case is something like this:
- Open browser
- Open URL
- Enter User Name
- Enter Password
- Click on LogIn button
- Logout of the application
So, we already have a test that contains log In steps, so if we can reuse the same test for this new test then we will cover step 1 to step 5 without even spending effort on creating/recording a new login steps.
Create another Test
Let’s begin by adding a new test loOut_test.
Right click on the Project and select “Add New Test”
Provide the name logout_testto the newly added test
Once we have created a new test. We will add steps to it.
ReUse a Test as Test Step
As we already have Steps 1 to Step 5 defined in another test (logIn_test). So, to reuse this test we will have to add this test as a step to the newly added test.
To add another test as a Test Step, click on the “Test As Step” in the Step Builder pane.
Double click on the “Test As Step” link to add a test. This will open Select Test(s) pop-up for selecting a test.
This Pop-up contains a list of all the test cases present in the selected Project. Select a Test from the list. In our tutorial, we will select, logIn_test.
Click on the “Select” button to add the selected test as a test step for your new test.
The existing test will be added to the new test.
Now we will add next step. To add step next to this we will execute this test till the first step. As we have added logIn_test as our first step, so logIn_test will be executed.
So, it will be executed till here
Record the step for clicking on “SIGN-OFF” and add it. Now open Test Studio, we will find that another step for clicking Sign Off has been added to the test.
Now, execute the test to see how it works.