Creating a Virtual Asset from traffic
Parasoft Virtualize is a powerful tool that allows users to create virtual endpoints for clientside applications to test against. When creating these virtual endpoints, it is useful to be able to do so via traffic files. The steps on creating these files are detailed in the post here.
In order to create your asset, right click the Virtual Assets project folder and select Add New > Virtual Asset. After naming your asset and clicking next, expand the traffic selection and choose Generate Parameterized Messages. The next screen will prompt you to select a traffic file to be used when creating your asset.
After selecting your Traffic file, the next step is to connect to a Data Repository. Virtualize comes packaged with an Embedded Data Repository that you can connect to, but it is recommended to use the MongoDB Data Repository that comes with your Virtualize installation.
When you have the repository up and running, you can check your configuration and connection to it here. Specify the name of the server as well as the name for the repository you would like to create, as well as the username and password for the server. Once all of your settings have been validated, click next.
On the message grouping screen, it will automatically detect the message format used by your traffic for both the requests and responses. Usually, you will want to have the messages grouped based on the operation/type and have the grouping criteria be request body.
The next screen in this wizard is the message grouping review. If there are multiple requests/responses for the same call, there will be the option of selecting autoconfig here to go with some default values selected by Virtualize. If your service correlates on one specific element in a response, though, it is recommended to uncheck autoconfig.
The next screen will allow you to set correlations for the elements in different requests. To view these correlations, click on the request correlation tab at the top of the window. If you had the autoconfig option available, you will see all of the values the option would have chosen for correlation here. If not, all boxes on this tab will be blank. To set a correlation, click the "new" button on the right of whichever set of info you would like to correlate on.
Once you have selected all of the different correlation options, you will be able to set your data reuse options in the data repository. There are several options here that may need some explanation:
Data Set Import
- Update: Keep all old and new data, and if there is any overlap in the data, overwrite the old data with the new.
- Replace: Discard all previous data and keep new data.
- Merge: Similar to update, but if there is overlap, discard the new parts of the data.
- Overwrite: Overwrite any overlap in the old data from new data, then discard the rest of the new dataset.
- Reuse: Keep all old records, discard all new.
- Update: Keep all records.
If you have any questions about these, refer to the Venn Diagrams that describe the repository's behavior. It is usually recommended to use Update - Update for the two values.
Step 6 (Optional)
You can then, if you so choose, create a template for many of the steps you just took. The template will save all of the different options that you chose for the different steps and apply those the next time you would like to create a pva from the same service from traffic or update the repository with more data.
The final step is to change the endpoint of the asset if you wish, though if you use the Virtualize proxy to record your traffic, you will want to change the endpoint so that it is unique (by default it will have the same endpoint as the proxy you recorded it from).