Relative Paths to Project Resources

Applies to ReadyAPI 3.57, last modified on December 20, 2024

By default, ReadyAPI uses absolute paths to files. This approach may be flawed when you use the same test on multiple machines or share it with multiple users, because not all of them will have the files you need in the same place. To solve this issue, use the Resource Root project property. If this property is specified, ReadyAPI uses relative paths starting from the specified folder.

How to change the property

Selecting the Root Folder

You can specify the root folder in the Resource Root project property and the absolute path to the folder location, or use one of the following options:

  • ${projectDir} – The path to the location where the project XML file or composite project folder is stored.

  • ${workspaceDir} – The path to the folder containing the workspace file. The default ReadyAPI workspace is stored in the C:\Users\<username>\ folder.

For TestEngine and a composite project that uses external resources (like Groovy script) please follow the rules described below:

  • Composite project zip archive must contain a folder with files - not files only.

  • That folder name is used while the Test Case is importing an external library (like Groovy). For example - if in Test Case script is importing the library in the following way:

    <script>
    import Sample.Callee;
    /* script code */
    </script>

    then composite project folder name must be equal to “Sample” because for
    scriptLibrary="${projectDir}"

    project library location is resolved as:
    ${projectDir}/Sample/Callee.groovy

    Please see here for example of how a Zip file needs to be structured for customer reference.

LoadUI agent do not support using ${projectDir} and ${workspaceDir} as values of the Resource Root property.

Default value

By default, the value of the resource root property is empty. In this case, if you import a project on another machine and files associated with it cannot be found in the folders specified in the project, ReadyAPI will automatically look for them in the project folder.

Sample Usage

Relative paths are most commonly used to share projects and related files by using source control systems. In this case, the project, workspace and related files are stored in the same folder. For example:

The Reference Files folder

In this case, both ${projectDir} and ${workspaceDir} lead to the same folder. Then, you can continue from it to get the files you need. For example, to get a file in the Reference Files folder, you can use the Reference Files/SampleFile.xml path.

See Also

Best Practices
Project Properties

Highlight search results