3.12.8. Replacing a specific Test Case at places where it has been reused
Prev | 3.12. Working with Test Cases | Next

### 3.12.8. Replacing a specific Test Case at places where it has been reused

If you have reused a Test Case at multiple places in your Project, and later create a new Test Case that should replace it, then you can perform a mass replace via the Search Result View. If you just want to replace one single place where a Test Case has been reused, then you can either select that Test Case in the Search Result View or use the in-editor replace (Section 3.10.13, “Replacing Test Cases in editors: Refactoring”).

| In order to perform a mass replace, all Test Cases to be changed must not be in use by anyone else using the Project – you should ensure that this is the case before performing the replace, otherwise the replace cannot be carried out. You should also be aware before performing this action that it cannot be undone.

1. Search for all places where the Test Case you want to replace is used e.g. Show where used (Section 3.30.2, “Searching for places where a Test Case or Test Suite has been used”).

2. In the Search Result View, you will see all places where the selected Test Case is reused in this Project, including in other Test Cases, in Test Suites and anywhere you have used the Test Case as an Event Handler. Select all entries, or just the Test Case references you want to replace with a new Test Case reference.

   | You will only be able to perform the replace if all selected Test Case references use the same original Test Case. The context-menu entry will be disabled if the Project is protected, or any of the selected Test Cases are missing (e.g. from reused Projects).

3. From the context menu, select:

   Replace with another Test Case

4. The first page of a wizard will appear. Here, you can choose the Test Case you want to use as a replacement at the places you selected. It is a good idea to select a Test Case that ”fits well” (in terms of any component names it propagates and parameters it references) to the Test Case you are replacing. You will be able to map any compatible components and parameter names in the next steps.

5. Press ”Next” to continue to the next page of the wizard.

6. On this page, you can match any component names propagated (Section 3.15.5, “Propagating component names”) from the newly selected Test Case to already existing propagated component names from the old Test Case. On the left-hand side, you can see names that are propagated from the newly chosen Test Case. On the right-hand side, you can:

   - match the new names to existing names if there are compatible names available in the existing Test Case. The information for names you match in this way will be transferred from the existing Test Case to the new Test Case when the replacement occurs. Any new names entered, or further propagations at the places of reuse, will also be transferred. This is the best way of ensuring that your Project structure is the same after the replace.

   - choose to leave any combo boxes empty. In this case, no match for that component name will take place, and the new component name will be used.

   - see if there are no names available, either because there is no compatible type for matching in the existing Test Case, or because the existing Test Case had no propagated component names. In such cases, the new component name will be used.

   | For any non-matched (or non-matchable) component names, the new names from the new Test Case will be used. This may result in incomplete object mapping for your tests.

7. Once you have matched any component names, press ”Next” to continue to the next page of the wizard.

8. On this page, you can match any referenced parameter names (Section 3.14.3, “Using references for data in Test Cases”) from the newly selected Test Case to already existing referenced parameter names from the old Test Case. On the left-hand side, you can see parameters that are referenced from the newly chosen Test Case. On the right-hand side you can:

   - match the new parameter to existing parameters if there are compatible types available in the existing Test Case. The data for any parameters you match in this way will be transferred from the existing Test Case to the new Test Case when the replacement occurs. Any test data entered locally, any test data referenced from the original specification, and any central test data sets or Excel tables used, will also be transferred. This is the best way of ensuring that your Project structure is the same after the replace.

   - choose to leave any combo boxes empty. In this case, no match for that parameter will take place, and the new parameter will be used. You can set a default value for this parameter on the next page.

   - see if there are no names available, either because there is no compatible type for matching in the existing Test Case, or because the existing Test Case had no referenced parameters. In such cases, the new parameter will be used after the replace. You can set a default value for this parameter on the next page.

   | For any non-matched (or non-matchable) parameters, you can set default values on the next page.

9. Once you have finished matching the parameters, press ”Next” to continue to the next page.

10. On the last page you can set default values to those parameters which were unmatched on the previous page. These default values cannot contain references, but all other data types are allowed (e.g. variables or functions).

11. Once you have finished setting the default values, press ”Finish” to perform the replace.

| The Test Case reference names and any comments that were used for the original Test Case references, will be transferred to each new Test Case reference. If the original Test Case reference was commented out, the replacement Test Case reference will be as well. If you had used the original Test Case as an Event Handler, the Event Handler details will also be transferred.