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.

Note: If there is no primary key on a database table that is being "learned", the simulation database might contain duplicate records when the learning is complete. A warning message is displayed in the Recording Studio warning message block and the server activity log if HCL OneTest API detects a table without any primary keys.
To create a database stub from recorded SQL events:

Procedure

  1. 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.
  2. 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.
  3. Click the Yes, record the SQL and create a virtual database option button.
  4. Click the Create a database stub and start it option button or the Create a database stub but don't start it option button.
  5. In the Stub name field, enter a name for the stub.
  6. Click Start Recording.
  7. 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.

  8. 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.