In this chapter, we’ll discuss how to get data into the testing infrastructure. We will use an instance of the Parabank example application shipped with Parasoft SOAtest and Virtualize and add a proxy to the application configuration so that we can capture the data to a data repository.
In this section:
We’ll start by deploying the ParasoftJDBC driver to Parabank and configuring a connection to the SOAtest/Virtualizer server. The Parasoft JDBC driver is a special JDBC driver that can act as a man-in-the-middle between the application and its regular JDBC driver. See About the Parasoft JDBC Driver to learn.
Open the ParaBank/src/jdbc.properties file and specify the following settings:
jdbc.driverClassName=com.parasoft.xtest.jdbc.virt.driver.JDBCProxyDriver jdbc.url=jdbc:parasoft:proxydriver:org.hsqldb.jdbcDriver:@jdbc:hsqldb:hsql://localhost/parabank jdbc.username=sa jdbc.password= |
Under the Arguments tab, add the following Parasoft JDBC Driver flags to what is already listed in the VM arguments section:
-Dparasoft.virtualize.server.url=http://localhost:9080 -Dparasoft.virtualize.group.id=parabank -Dparasoft.virtualize.driver.register.jdbcproxydriver.in.drivermanager=true -Dparasoft.virtualize.driver.proxy.direct=true |
If you are applying this tutorial to your own project, the documentation includes instructions on how to deploy the Parasoft JDBC Driver to several application. See Using the Parasoft JDBC Driver.
In this step, we will record a database query and use it to create a virtual asset. Recording a database query will not add data to a data repository. An action, such as sending a message to virtual asset connected to the repository, must be taken in order to capture the data. You can perform this step in the Virtualize desktop or in CTP. We will use CTP in this tutorial, which requires some additional configuration.
We’ll create a new system, environment, and database component in CTP. A system is a representation of your development infrastructure. A system contains one or more representations of your environments, such as "regression testing", "integration testing", etc. Additionally, you can create several instances of an environment to meet your testing needs.
A system is a palette that is populated with several components, such as databases, servers, clients, etc. An instance of each component contains configurations used within specific environments. A realistic system would contain several components, but we will only use the database component to illustrate the workflow:
You should now a have a system called Parabank that consists of a single database. The system contains the Silo 1 environment. We will next add multiple instances of the database component to configure different states.
A component is a type of object that can appear in your environments. You have to add instances of the component that perform specific functions for them to be useful.
You now have a passthrough mode and a record mode configured for the database component. The next step is to enable recording and capture a query.
The next step is to create a virtual asset connected to a data repository to capture the data associated with the query. We will use Virtualize desktop to complete this step.
The data is not captured when you record a database query using the JDBC driver—only the query templates. We will create a virtual asset using the database query templates and attach a data repository and message responder to capture the data.
ParabankLogin
in the File name field and click Next.ParabankDB
in the Repository name field. You can also specify an existing repository, but the data will be overwritten by the data captured when the virtual asset queries the database. The repository is a collection of related data sets.parabank-login
. A data set is a collection of related data fields.The virtual asset will populate the data repository with data from the database using the recorded SQL templates. Open the Test Data module in CTP and click on your repository to access the data.
Now that we have data captured in a database, we'll make a snapshot of the data repository so that we can always reset the data to its initial state if necessary.
The next step is to configure a virtual database instance that will pull data from the repository for testing purposes.
You can verify that the virtual database is being used with data from the repository by using Test Data to make a change.
At this point, you can clone and modify records and use the data in your API and manual UI tests. But we will use even more powerful Test Data features to scale and modify test data to meet any stage of the software testing lifecycle.