[QUESTION] Unable to use non-default robot.toml configuration when running tests from VSCode GUI
I want to have my robot.toml configuration in non-default locations. For most part this works fine
- I can run tests through CLI nicely by passing the correct
robot.tomlin with--config - VSCode language server works nicely if I configure
robotcode.languageServer.extraArgs
What does not work for me is running/debugging tests with VSCode
- If I configure
robotcode.extraArgsthey do not seem to get passed to the robotcode when starting test runs from VSCode GUI (Testing View or Editor). Test runs are started withrobot.tomlconfiguration in one of the default paths instead.
Is there an option I am missing that would allow me to configure which robot.toml file to use when starting test runs from VSCode GUI?
- VS Code Version 1.94.0
- RobotCode Version [0.93.1]
- OS: [Windows 10]
- Python Version [3.11.8]
- RobotFramework Version [7.0.0]
How can the robotcode.extraArgs be configured? Could you provide an example?
Additionally, what is the rationale for using non-default locations?
In VSCode there is robotcode.extraArgs setting. I would like to use --config to give path to robot.toml
Rationale for non-default locations is that our git repository has tests, which can be ran with multiple different hardware setups.
Based on hardware setup we create configuration file which has arguments for robot, which decide which keyword resource files are used for Suite and Test setup, what communication protocols are used to command the devices, and where related protocol message definitions are.
For language server to work correctly it needs to be aware of python paths and robot variables configured. Similarly for test-runner. It would be ideal if we could use robot.toml as the single source of configuration, instead of defining same configuration multiple times separately for CLI, language server and runner.
Putting the robot.toml in default location and using profiles is a possibility and not out of question. But for my use case maintaining multiple test environment profiles in one file is more complicated than maintaining one robot.toml file per test environment.
I will investigate this a bit further. It might be possible to use a launch.json with a default configuration to start tests, but it sounds a bit complicated. Perhaps a VSCode setting to specify different configurations would make more sense, instead of using ExtraArgs.
However, there is another request for supporting multiple TOML files: https://github.com/robotcodedev/robotcode/issues/282. This might be a better solution for your challenge. The implementation shouldn't take too long. I would lean towards option 2, as you would only need to create the files, and robotcode would take care of the rest. What do you think?
Option 1 (config-files directive) in #282 would let me couple the configuration files with the various test_environments in the way I'm looking for. Then I could do
[profiles.test_env1]
config-files = ['test_env1/robot.toml']
[profiles.test_env2]
config-files = ['test_env2/robot.toml']
And still use --config test_env1/robot.toml on the CI pipeline side.
Option 2 falls bit short in that the test_environments would still be decoupled from their configuration files and conflict resolution between configurations for different environments would have to be done inside robot.toml.d/ through profile directive. This would make using same robot.toml on our CI pipeline side more complicated since specifying correct config file wouldn't be sufficient anymore, but profile selection would be necessary on top, even if the config in robot.toml.d/ would only contain one profile.
At the moment, you need to use the robotcode.languageServer.extraArgs setting with -c, path_to/config.toml, and if you want to run the tests, you have to create a .vscode/launch.json file in your project and specify the same settings there again.
Something like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "RobotCode: Default",
"type": "robotcode",
"request": "launch",
"presentation": {
"hidden": true
},
"purpose": "default",
"robotCodeArgs": [
"-c",
"path_to/config.toml"
]
}
]
}
You need to adjust the paths, of course ;-)
I'm thinking of a way to configure this better, or I'll implement issue #282, or both, but that will take a little while...