Creating database stubs by using the Recording Studio
You use the Recording Studio perspective of the HCL OneTest™ API to create a database stub while SQL events are being recorded from a database.
About this task
To create a database stub, you must record SQL statements from a live
application to populate the stub with data from the live database. Each SQL SELECT
statement that is recorded will be analyzed by HCL OneTest™ API and the
corresponding results from the live system will be copied into the database stub that is being
"learned" during recording. HCL OneTest™ API attempts
to copy the data matching the SQL WHERE
clause.
For example, if the recording contains only the reading of one customer, the database stub will contain only data about that customer. Alternatively, if the recording contains the reading of, say, all customers with the first name "John", the database stub will contain the same data.
Procedure
- In the Recording Studio perspective, select
(for recording) the database that you want to stub. Note: The database selected must be the database that was specified in Prerequisites for creating database stubs.
- Click the Record button
() on the Events View toolbar. The Create Stubbed Database Whilst Recording? dialog box is displayed.Note: The dialog box shows the last inserted values, if any. You can retain the values or edit them.
- Click the Yes, record the SQL and create a virtual database option button.
- Click the Create a database stub and start it option button or the Create a database stub but don't start it option button.
- In the Stub name field, enter a name for the stub.
- Click Start Recording.
- Run a test case or a test case suite against
the live system to populate the stub with sufficient data to make
it useful.
You will be able to add more data to the stub later. During recording, Recording Studio will display information relating to stub creation, such as messages about database table creation. However, the stub will not be created until you stop recording.
- On the Create Stubbed Database Whilst Recording?
dialog box, click Stop Recording.
If you had selected the Create a database stub and start it option or the Create a database stub but don't start it option, the stub is now created.
If you had selected the Keep learning option, you must execute another (or perhaps many more) stub recording sessions to generate sufficient SQL to create the stub.
Results
In the Test Factory perspective, the newly created database stub is displayed under the relevant logical resource on the component tree.
You can now start, stop, or modify the new database stub.