Applies to LoadNinja 1.0, last modified on June 14, 2019

Why use databanks in tests?

The test runner simulates test events using hard-coded parameter values, that is, the values that you entered during the script recording or editing.

To get larger coverage and check how your web application works with different input values, run your test using varying data — for example, record a number of scripts each entering different data. An easier solution, however, is to use some file as a data source (or databank), read it row by row, and run test commands for each row in that databank. Such tests are called data-driven load tests.

Databank formats

The databank must be a CSV or TXT file, with either commas or tabs as a value delimiter. The first line may contain column headers.

How it works in LoadNinja

To create a data-driven load test in LoadNinja, attach databanks to individual scripts that your load scenario will run. Then, map databank columns to event parameters as explained below.

LoadNinja supports this type of parameterization for the Keyboard Input events, Select Input events, and web page URLs.

During the load test execution, each script will typically run several times. For each iteration, LoadNinja will pick a databank row and insert column values from this row into event parameters:

Data-driven testing with LoadNinja: Using data rows in test iterations

Click the image to enlarge it.

How LoadNinja picks values from the databank

By default, LoadNinja picks databank rows randomly. To change this behavior, go to  Settings in the script recorder and change the value of the Run Databank Rows setting:

Run Databank Rows setting

Click the image to enlarge it.

Possible options are —

Value Description
Random Default value. LoadNinja will pick random data rows from the databank for each iteration and each virtual user.
During the test run, there is a possibility that multiple users will use the same data at the same time.
Depending on the number of iterations and the number of rows, some rows are used more or less frequently than others. If the number of iterations is significantly larger than the number of rows, each row will be used approximately the same number of times.
Sequential For each virtual user, LoadNinja will pick data sequentially for each iteration, that is, the first iteration of a virtual user will use the first databank row, the second iteration will use the second databank row, and so on.
Each virtual user processes the databank on its own, so it means that multiple virtual users may be using the same data at the same time.
Unique At any given time instance, LoadNinja will pick unique data rows for virtual users, so they will never use the same data at the same time.
The number of databank rows should be equal to or greater than the number of virtual users that will run this script.

Attach a databank to a script

1. Prepare the databank

Create a .csv or .txt file with the desired data, using either commas or tabs as value delimiters. Use any text editor to create the file. Many spreadsheet applications such as Microsoft Excel, Numbers, and LibreOffice Calc also export data to CSV.

Tip: We recommend that the first line contains descriptive column headers. In this case, the test will display the column names rather than indexes (1, 2, …).

2. (Optional) Record a script

If you do not have a test yet, record it. Replay the recorded test once to make sure it works correctly.

3. Import a databank
  1. In the script recorder, select Add > Databank on the toolbar:

    Upload Databank

    Click the image to enlarge it.

  2. Click Browse and select one or multiple .csv or .txt files from your device you want to use as databanks.

    To remove the file you have accidentally added from the list, click near that file.

    Import Data Bank

    Click the image to enlarge it.

    Click Next: Define File Format to proceed.

  3. In First row contains, specify whether the first row of each file you have attached should be treated as a header or a data row. In the Column delimiter column, select the symbol that separates columns within your databank.

    Import Data Bank: Structure

    Click the image to enlarge it.

    Click Next: Review Import. LoadNinja will try reading data from your files.

  4. LoadNinja will display a preview of the data. If the data does not look right, click Back and change the parsing settings.

    Import Data Bank: Preview

    Click the image to enlarge it.

    If LoadNinja loaded data correctly, go to the next page by clicking Next: Map Data to Script.

  5. On the next page, map column values to test commands in your script. LoadNinja will locate parameters within the test and list them.

    To command LoadNinja to use a databank for replacing parameter values, do the following for each input event:

    • Select a file you want to use as the databank in the Map file column for a parameter.

    • Select the databank column from which the input values will be taken during the playback.

    In both these cases, select No Mapping to skip this setting and use the hard-coded recorded value during the playback.

    Tip: To change these mappings later, simply click # databank(s) in the script recorder.

    LoadNinja will show a preview of the item in the first data source’s row in the rightmost column:

    Import Data Bank: Map Values

    Click the image to enlarge it.

    To learn how to map values in the script recorder, see below.

  6. Click Next: Save Mapping.

LoadNinja will upload your data file to the cloud and update the test. Events that use values from a databank will have the corresponding label:

A script event that uses a databank
Note: Databanks are not shared among scripts. To use the same databank in another test, attach it to that test separately.

Change event-to-data column mappings

To change the databank columns used for events, use the # databank(s) dialog or edit the event parameters directly.

For all events

  1. Click # databank(s) on the toolbar.

    Modify Databank
  2. Update the mappings as required and click Save.

For a single event

Currently, LoadNinja supports this feature only for Keyboard Input events. For parameterizing URLs and selection inputs, consider creating a mapping while uploading a databank.

  1. In the list of test steps, find the Keyboard Input event you want to parameterize.

  2. Expand the event parameters and click .

    Mapping values: Start

    Click the image to enlarge it.

  3. Select or unselect the Use Dataset check box as required.

  4. If Use Databank is selected, select the databank column to take the parameter value from.

  5. Click Submit.

Update or replace a databank

LoadNinja stored databanks along with the tests which use these databanks. After you attached a databank to a script, the # databank(s) button appears on the toolbar. To update or replace the databank, follow these steps:

  1. Click # databank(s) on the toolbar.

    Modify Databank
  2. (Optional) Remove the obsolete databanks by clicking near them.

  3. Browse for the new databank and click Next: Define File Format.

  4. Configure the importing settings, as you do for the new databanks.

  5. Check the preview.

  6. If the new databank has a different set of columns, update the event-to-column mappings as required.

  7. Click Save.

Test events that are connected to the databank will use the values from the specified data row. Here, "Name" is the databank column mapped to this event.

let test_data1 = DS_test_data[random_test_data]["Name"]; // Get the value
await driver.sendKeys(test_data1); // Use the value

See Also

LoadNinja Documentation

Highlight search results