...
These two capabilities are typically used in sync to ensure rapid, accurate updating. This lesson will show you how to use both capabilities to update tests.
Creating Tests Against an "Old" Version of a Service
Start by creating a set of tests for an older version of a bookstore service. We’ll later update these tests using the Change Advisor and Search and Replace capabilities.
...
Using this assertor, we are declaring that the element price
occurs exactly once in the SOAP response message. If this element is later changed in the updated version of the service, we will have to re-configure the updated test’s XML Assertor.
Performing Change Impact Analysis
To perform change impact analysis on these test assets:
...
Note that the Change Impact results do not show all changes that are in the service definition; they show only service definition changes that actually affect the tests. For example, if there were changes in operations that were not currently being tested, then no change impact results would be reported for those changes.
Creating a Change Template
When the Change Impact analysis is run, the Service Catalog view is automatically populated with information about the services and versions of the services that are being tested by the tests being analyzed.
...
- Rename the service and versions to something that we can better understand:
- In the Service Catalog, right-click the top-level service node, then choose Rename Service.
- Enter
Bookstore
as the service name. - Right-click the Old Version node for the bookstore service, choose Rename Version, then replace
Old Version
with1.0
. - Right-click the Current Version node for the bookstore service, choose Rename Version, then replace
Current Version
with2.0
.
Next we want to define a change template that will define how we should update our tests so that they test the new version of the service.
- Create a change template as follows:
- In the Service Catalog, select the nodes 1.0 and 2.0.
- Right-click the selection, then choose Add Change Template 1.0 -> 2.0.
- Enter
LessonTemplate
as the file name, then leave/Change Advisor Lesson
as the location. - Click Finish. The change template editor will open.
- Review the first tab of the change template that was created. Note that:
- The Map Operations tab displays the operations defined in both WSDLs, as well as a default mapping between the different versions of the WSDL. When SOAtest first creates a change template, it creates a default mapping between the different versions, attempting to match nodes that it thinks are the same.
- Green matches denote the fact that SOAtest is confident that the mapping it made is correct, and review is not required.
- Yellow matches denote that SOAtest is less confident that the mapping it made is correct, and review is recommended to confirm or update the mapping.
- Here, all operation mappings are shown in green—except for the mapping between the operation
getItemById
andgetItemByIdentifier
. It appears that this operation changed names, but that the meaning of the operation is the same. This seems like a good match.
- Indicate that we’ve reviewed the mapping between the operation
getItemById
andgetItemByIdentifier
by right-clicking getItemById and choosing Mark Match getItemById -> get-ItemByIdentifier as Reviewed". This will make the match turn green. - Review the second (Map Schemas) tab of the change template that was created. Note that:
- This tab displays the schemas defined for each operation. You can double-click on the editor tab to cause it to expand so that the editor is larger.
- The
addNewItemToInventory
operation is marked with a red ‘X’, indicating that there are differences in the schema for that operation that need to be reviewed. - Other operations do not need review since SOAtest did not detect any changes in those operations in need of review. If you select each of the operations without the red 'X' icon, you’ll see that all matches are in green.
- Select the addNewItemToInventory operation to explore it. Note that
- SOAtest matches the
price
andgenre
elements, but indicates that they need review - The operation contains a new element named
amount
that did not appear in the original version.
- SOAtest matches the
- Indicate that the mapping between the
price
andgenre
elements is incorrect by selecting the price element and clicking Disconnect.
It appears that theprice
element was renamed toamount
, and thatgenre
is the new element in the WSDL. - Indicate that the
price
element was renamed toamount
by select price and amount, then clicking the Connect button.
Thegenre
element is a new element that appears for this operation. In order for our tests to be updated properly, we must configure a default value for that element that will be configured in each of the updated tests. Otherwise the updated tests would send an empty value for that new element. - Configure a default value for the
genre
element as follows:- Right-clicking genre and choose Configure Default Value for Added "genre" element.
- In the dialog that opens, enter
Literature
in the input field, then click OK. - Notice that
genre
now has a green ‘?’ and that all matches and unmatched nodes are now green. This indicates that we’re finished reviewing and configuring this operation.
- Right-clicking genre and choose Configure Default Value for Added "genre" element.
- Indicate that the three parent nodes of amount have been reviewed by right-clicking the highest productInfo element and choosing Mark"productInfo" and Children as Reviewed.
- Save the template by clicking the Save toolbar button. At this point, our template has been defined and is ready to be applied to our tests. Double-click the change template editor tab to bring it back to normal size.
Applying the Change Template to Update Tests in Bulk
To update the tests impacted by this service change:
- In the Test Case Explorer, select Change Advisor Lesson.tst, then click the Refactor Using a Change Template toolbar button.
- Complete the wizard as follows:
- Complete the first page as follows, then click Next.
Version: 1.0
Update Parasoft assets to use service version: 2.0
By applying the change template: LessonTemplate In the second page, leave New Location selected, then use the Workspace button to select the Change Advisor Lesson project. This will cause the updated tests to be saved in a new folder within the Change Advisor Lesson project. Note that, in some cases, you might want to overwrite your previous tests. However, this is highly discouraged unless you have the tests backed up (e.g., using a source control system). Otherwise, you will lose your original tests.
Click Finish. A new folder called "Change Advisor Lesson" will be created. This folder contains the updated tests.
- Complete the first page as follows, then click Next.
- Open the .tst file, and open the editor for Test Suite: Test Suite> Test Suite: CartService-Port> Test 2: addNewItemToInventory. Note that:
- If you select the productInfo element, you’ll see that the value that we had configured for the
price
element has been transferred to the amount element, as defined in our change template. - The other values that we inputted earlier have carried over to the new test. Select the genre element, and note that the value
Literature
appears there, as defined in our change template. - A new, updated environment has been added to the Environments node of the new folder, and it has been set as the active environment.
- If you select the productInfo element, you’ll see that the value that we had configured for the
- Select the new folder Change Advisor Lesson> Test Suite: Test Suite, click the Run Change Impact Analysis toolbar button, select Scan selected assets against their current service description radio button, then select Finish. Note that no changes are reported, since the new tests are now updated to test the current version of the service.
Updating Tests Using Search and Replace
Change Advisor is applicable for tests that are configured:
...