Creating tests from recorded events

Tests can be created by using events that are captured in the Recording Studio.

Procedure

  1. In Recording Studio, select one or more recorded events in the Events View.
  2. Click the Create Test from selected events icon in the Events View toolbar, or right-click the messages and select Create Test or Create Parameterized Test from the menu.
    If you use a tag reference from a promoted column as part of the test name (for example, col = %%Col A%%), grouping is enabled as follows:
    • The cell from any promoted column that does not contain a value inherits its value from the first non-null value above it.
    • All rows that share values belong to the same group.
    • If more than one tag name is used in the name, uniqueness is applied to the applicable columns
    • Each group produces a set of tests (unit, or integration, or both).
    • Generated tests are driven from only the subset of events that are defined in each group.
  3. On the Resource Type page, select one of the following test types:
    Create > integration tests
    To create a test that is based on the actions in the selected events.
    Create > unit tests
    To create a test that is based on the MEP types of the selected operations.
    Add to > existing stub or test

    Messaging events can be added to existing stubs. JDBC events can be added to existing tests. The appropriate resources are displayed in the Browse dialog. Select the resource to add the events to.

  4. Click Next.
  5. On the Data Storage page, choose one of the following methods for storage:
    as hard coded values
    Create one or more test messages with hardcoded values from the events.
    in a simple data set
    Create one or more test messages with tags. The tags refer to a new data set that has the same name as the base name of the message and that contains the values from the events.
    in a data model
    This option is not available for tests.

    Click Next.

  6. On the Operation Assignment page, you can change the default names assigned to the displayed operations. Click Next when you are finished.
  7. If you are creating a data set, the Transaction Assignment page is displayed. Group events together that represent a single transaction by selecting events and clicking Group or Ungroup. Click Next when you are finished.
  8. If you are creating a data set, the Column mapping pages are displayed, one page for each event. Double-click the displayed column names to change them. Click Next when you are finished.
  9. In the Header Transformation window, all HTTP headers that were identified in the recorded traffic are displayed. Only those headers that are useful in distinguishing one operation from another are enabled. The remaining headers are disabled to make the message or messages more generic. Change any of these assignments if necessary, and click Next.
  10. On the Summary page, enter a name for the test. To edit the new test immediately after it is created, select Open resource after finish. Click Finish.

Results

A test is created. The test contains test steps that relate to the selected events. Test steps vary on the type of event.

The following table lists some examples of test steps that are generated from recorded message-based events:

Table 1. Examples of test steps that are generated from recorded message-based events
Message event type Test step Properties
Publish Publish action
  • Config
    • Transport
    • Message Header
  • Value
    • Data from the recorded message.
Receive reply Receive reply action
  • Config
    • Transport
    • Message Header
  • Assert.
    • Data matches that from the recorded message.

The following table lists some examples of test steps that are generated from recorded SQL events:

Table 2. Test steps that are generated from recorded SQL events
SQL event type Test step Properties
INSERT, UPDATE or DELETE SQL Command action
  • Settings
    • Database server
    • SQL Statement
  • Actions
    • Compare the affected number of rows with that in the recorded event and check that the number is equal.
SELECT SQL Query action
  • Settings
    • Database server
    • SQL Statement
  • Assert.
    • Data matches that from the recorded result set.
CALL SQL Command action
  • Settings
    • Database server
    • SQL Statement.