Configure Your Project
RobotCode reads the configuration of a Robot Framework project from a robot.toml file in the project folder. It holds the options you would otherwise pass to robot on the command line or in argument files, such as the paths of the tests, the Python path and variables, and profiles for different environments. The editors and the robotcode commands use it alike, so the tests run the same way everywhere. This page creates a first robot.toml; Configuring Projects with robot.toml explains all that it can do.
A first robot.toml
Section titled “A first robot.toml”Create a file named robot.toml in the root folder of your project, and commit it:
paths = ["tests"]python-path = ["libraries", "resources"]output-dir = "results"
[variables]BROWSER = "chromium"BASE_URL = "http://localhost:8080"paths: the folders or files with your tests.python-path: folders in which Robot Framework looks for your libraries and resource files.output-dir: the folder foroutput.xml, the log and the report.[variables]: variables for all tests, as--variablesets them on the command line.
Each setting is a command line option of Robot Framework, written with its long name in words separated by hyphens: --outputdir becomes output-dir, and --pythonpath becomes python-path. Relative paths count from the project folder.
In VS Code, the extension Even Better TOML completes the settings and shows their documentation, see Editing robot.toml. PyCharm completes the settings without further setup.
Running the tests
Section titled “Running the tests”VS Code and PyCharm use the configuration for the analysis, the test discovery and runs, and pick up a change of robot.toml at once.
On the command line, run the tests with robotcode run; Robot Framework's own robot command does not read robot.toml. robotcode run needs RobotCode's runner in the environment of your project:
pip install "robotcode[runner]"# run the tests in pathsrobotcode run
# options and paths on the command line come on toprobotcode run -i smokerobotcode run tests/login.robotAn option with a single value on the command line, such as -d, replaces the one in robot.toml; a repeated option such as -i adds to its list, and paths on the command line replace paths.
A profile for another environment
Section titled “A profile for another environment”A profile holds the settings for another environment. Add one to robot.toml:
[profiles.staging]description = "Staging shop"
[profiles.staging.extend-variables]BASE_URL = "https://staging.shop.example"robotcode -p staging run runs with it. extend-variables adds to the variables outside of the profile, here changing BASE_URL and keeping BROWSER; variables would replace them all. In VS Code, RobotCode: Select Configuration Profiles selects the profiles, and in PyCharm Tools | RobotCode | Select Configuration Profiles.... Profiles explains default profiles, inheritance and the order of profiles.
Personal settings
Section titled “Personal settings”Settings that only you need go into a file named .robot.toml next to robot.toml. Add it to .gitignore:
[extend-variables]BROWSER = "firefox"RobotCode reads .robot.toml after robot.toml. Its settings replace those of robot.toml, and with extend- they add to them: [variables] here would drop BASE_URL. See Personal settings in .robot.toml for more uses.
Checking the configuration
Section titled “Checking the configuration”robotcode profiles show prints the settings that a run gets, and robotcode -p staging profiles show those with the profile staging. robotcode config files lists the files that RobotCode reads.
Next steps
Section titled “Next steps”- Configuring Projects with robot.toml explains the files, the settings, profiles, how settings combine and the command line, with recipes and troubleshooting.
- The
robot.tomlreference lists every setting. - RobotCode's other settings are explained for VS Code and PyCharm.
Released under the Apache-2.0. Copyright © 2022-present Daniel Biehl