robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[ENHANCEMENT] Introduce `cwd` Setting in `robot.toml` to Specify Start Path for Robot

Open d-biehl opened this issue 1 year ago • 2 comments

Description: In many projects, RobotFramework tests and their associated libraries are organized in subdirectories. To improve the flexibility and usability of these projects, I propose adding a cwd (current working directory) setting in the robot.toml file. This setting will allow users to specify the start path for robot, making it easier to manage and execute tests located in various subdirectories.

Proposed Changes:

  1. Add a new cwd setting in the robot.toml configuration file.
  2. Modify the RobotFramework execution logic to use the specified cwd as the starting path for test discovery and execution.

Benefits:

  • Enhanced flexibility for projects with complex directory structures.
  • Simplified configuration and execution of tests in subdirectories.
  • Improved usability for teams organizing their tests and libraries in various folders.

Example robot.toml Configuration:

[robot]
cwd = "path/to/tests"

d-biehl avatar Aug 07 '24 08:08 d-biehl

Currently, I have the following in my .vscode/settings.json:

{
  "robotcode.robot.env": { "EXECDIR": "${workspaceFolder}" }
}

Our team "anchors" our path references to ${EXECDIR} in our suites and keywords so we don't have to worry about relative/absolute pathing issues. Hence - the above declaration.

Abridged Example

*** Settings ***
Resource          ${EXECDIR}/Resources/keywords/global.resource
Library           ${EXECDIR}/Resources/python_libraries/RobotFrameworkUtilities.py

It would be also useful if this enhancement could include/resolve VS Code variables such as the ${workspaceFolder} is via the settings file.

Perhaps this is already in play, but I wanted to raise visibility for this as well.

GLMeece avatar Oct 10 '24 16:10 GLMeece

@GLMeece, just to say a few words about this: and I'm sorry, that's not good style, because with RobotCode the ${EXECDIR} is always the ${workspaceFolder}, which you don't have to set explicitly

And instead of always having to specify such long paths with variables for the imports, you can simply put them in the Python path.

Simply add something like this to your robot.toml and then shorten it:

python-path = ["Resources/keywords", "Resources/python_libraries"]

the way you write your imports to that:

*** Settings ***
Resource          global.resource
Library           RobotFrameworkUtilities.py

This avoids unnecessary code duplication ;-)

And if you want to change the libraries/resource paths, for what reason ever, you only need to change the python-path and not every file...

d-biehl avatar Oct 10 '24 16:10 d-biehl