Directory Data Source

Applies to ReadyAPI 3.52, last modified on April 25, 2024

The Directory data source iterates through the files within the specified directory and puts the files' content to the first property specified in the Properties panel.

The data source assigns data to the first property in the list. Other properties will be blank, except for fileName (see below).

In this topic, we focus on how to configure the Directory data source. We assume you are already familiar with data-driven testing and how to configure a data-driven loop. Otherwise, please read Basic Concepts of Data-Driven Testing, or complete some of our tutorials before you continue.

You can only use this data source in the Data Source test step in functional tests. It is not available in virtual services.

Configuration

The Directory datasource

Click the image to enlarge it.

Directory

The directory to scan for files.

Filename Filter

Specifies a wildcard expression to filter files to read. For example, if you specify *.xml, the data source reads only XML files.

Encoding

Specifies the encoding used to read the files. By default, ReadyAPI uses the ASCII character encoding.

Note: You can use property expansions to insert values into the above-mentioned fields.

fileName property

To get file names, create the fileName property in the data source. On each iteration, this property will store the name of the file the data source is reading.

Do not use fileName as the first property of the data source, since it will overwrite the default assignment rules, and the files’ contents will not be available.

Let's imagine that we have a folder with files, and we want to send the content of the .json files as a request body and send the file name as a query parameter.

Directory data source example: Target directory

Click the image to enlarge it.

To do that:

  1. Create a data source loop with the Directory data source:

    Directory data source example: Directory data source

    Click the image to enlarge it.

    Tip: You can read about setting up data source loops here.
  2. Create two properties within the data source, fileContent and fileName.

    The data source will always write the file content to the first property, so make sure fileName is the second property in the list.
    Directory data source example: Data source properties
  3. Click Browse and select the directory that stores the files:

    Directory data source example: Select the target directory

    Click the image to enlarge it.

  4. In the Filename Filter field, enter *.json so that the data source only retrieves the content of the .json files:

    Directory data source example: Specify the filename filter

    Click the image to enlarge it.

  5. Click to check what data is retrieved:

    Directory data source example: Data log

    Click the image to enlarge it.

  6. To pass the data to the request test step, use property expansions to refer to the properties in the data source:

    Directory data source example: Passing data to request

    Click the image to enlarge it.

See Also

Basic Concepts of Data-Driven Testing
Data Source Loop Test Step
Data Source Test Step
Data Source Types

Highlight search results