Creating a dataset associated with a test

You can create a dataset that contains variable data for tests to use when they run. This is the preferred way to create a dataset because the dataset is automatically associated with a test. You can create anything from an empty dataset that contains one column, which you can edit later, to a fully functioning dataset.

Procedure

  1. In the Test Navigator, browse to the test and double-click it.
    The test opens.
  2. In the Test Contents area, click the name of the test.
  3. In the Common Options tab, click Add Dataset.
    The options listed in the following table, enable you to create anything from a simple dataset that you can edit later to a complete dataset.
    To create Do this in the Test Editor - Add Dataset window
    A one-column dataset with a default access mode. In Existing datasets in workspace, select New Dataset<testname>.csv, and click Finish. You can optionally name the dataset column in this session, and you can add other columns and data later.
    A one-column dataset and choose the access mode. In Existing datasets in workspace, select New Dataset<testname>.csv, and click Next. You can optionally name the dataset column in this session and you are prompted for the access mode. You can add other columns and data later.
    An association between the test and an existing dataset. Select the dataset. The dataset is associated with the test, and you can optionally set the access mode in this session.
    A new, fully functioning dataset. Select a project and click Use wizard to create new dataset.
  4. Select Open mode for the dataset. This mode determines the view that virtual users have of the dataset.
    Different tests can open the same dataset differently, and you can change the open mode later by opening the test and double-clicking the dataset title.
    OptionDescription
    Shared (per test execution) (default)

    When you choose the Shared (per test execution) option, the virtual users running in the test share the dataset values in sequential order.

    For example, if your dataset has 10 rows, the dataset values are taken from row 1, row 2, row 3, and so on when you select this option.

    Private

    Each virtual user draws dataset values from a private view of the dataset, with dataset rows apportioned to each user in sequential order.

    This option ensures that each virtual user gets the same data from the dataset in the same order. Because each user starts with the first row of the dataset and accesses the rows in order, different virtual users will use the same row. The next row of the dataset is used only if you add the test that is using the dataset to a loop in the schedule with multiple iterations.

    Shared (for all test executions)

    When you choose the Shared (for all test executions) option, the virtual users running in multiple tests share the dataset values from the current row.

    For example, if your dataset has 10 rows and when you set the current row as row 5, the dataset values are taken from row 5 instead of row 1 when you select this option. If you had set the current row as row 1 and used the dataset values until row 5, the dataset values are retrieved from row 6 when you run the test next time.

  5. If you are setting how the test accesses the dataset during this session, select one of the following options:
    • Sequential: Rows in the dataset are accessed in the order in which they are physically stored in the dataset file, beginning with the first row and ending with the last.
    • Random: Rows in the dataset are accessed in any order, and any given row can be accessed multiple times or not at all. Each row has an equal chance of being selected each time.
    • Shuffled: Before each dataset access, the order of the rows is changed that results in a different sequence. The rows are accessed randomly but all rows must be selected once before a row is selected again.
  6. Select one of the following options.
    OptionDescription
    Wrap when the last row is reached

    By default, when a test reaches the end of a dataset or dataset segment, it reuses the data from the beginning. To force a test to stop at the end of a dataset or segment, clear the Wrap when the last row is reached checkbox. Forcing a stop might be useful if, for example, a dataset contains 15 records, you run a test with 20 virtual users, and you do not want the last five users to reuse information. Although the test is marked Fail because of the forced stop, the performance data in the test is still valid. However, if reusing dataset data does not matter to your application, the default of wrapping is more convenient. With wrapping, you need not ensure that your dataset is large enough when you change the workload by adding more users or increasing the iteration count in a loop.

    Note:
    • With Random access order, Wrap when the last row is reached option is unavailable because you never reach the end of the row.
    • With Shuffled access order, if you select Wrap when the last row is reached option, you resume selecting from the beginning of the row with the same access order after each row has been selected once. No more selections are required if you clear the Wrap when the last row is reached option.
    Fetch only once per user

    By default, one row is retrieved from the dataset for executing each test, and the data in the dataset row is available to the test only for the duration of the test. Select Fetch only once per user to specify that every access of the dataset from any test being run by a particular virtual user will always return the same row.

    To illustrate how these options affect the rows that are returned, assume that a test contains a loop which accesses a dataset. The loop has 2 iterations. The following table shows the row that is accessed in each iteration:
    Dataset option Iteration 1 Iteration 2
    Sequential and Private row 1 row 2
    Shared and Shuffled row x row y
    Fetch only once per user row x row x
  7. If you are creating a fully functioning dataset, you can optionally import the data from a CSV file during this session by copying the CSV file and pasting into your project. For more information on importing dataset, see Editing datasets.

What to do next

After you have created a dataset and added data to it, the next step is to associate a value in the test with a column in the dataset, as discussed in Associating a test value with a dataset columnAssociating a dataset with the test.