Skip to content

Commit 84553c3

Browse files
committed
docs: update some documentation about config and cli
1 parent d5a9339 commit 84553c3

File tree

2 files changed

+93
-210
lines changed

2 files changed

+93
-210
lines changed

docs/02_get_started/configuration.md

Lines changed: 74 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,260 +1,143 @@
11
# Configuration
22

3-
## Introducing the `robot.toml` file
3+
## Introduction to the `robot.toml` File
44

5-
The `robot.toml` file offers an alternative way of setting up your project in VS Code. Usually, those settings would be done via the `settings.json` file, doing so comes though at the cost of several limitations and inconveniences. Using `robot. toml` alleviates many of those by:
5+
The `robot.toml` file provides a structured and flexible way to configure your Robot Framework project. Rather than relying on various argument files, batch files or command-line arguments, you can consolidate all key settings in this one centralized file. This makes it easier to manage and maintain settings across different environments and use cases.
66

7-
- providing a simpler way of defining settings for the Robot Framework project in one file
8-
- creating a file that can be easily shared and uploaded to a git repository
9-
- removing the need to create an argument file
10-
- simplifying the command line execution
11-
- allowing to define multiple, easily expandable, profiles
7+
Similar to how `pyproject.toml` has become a standard for configuring Python projects, the `robot.toml` file aims to serve the same role for Robot Framework projects. It allows you to define project settings such as output directories, environment variables, and profiles for different testing scenarios. This unified configuration approach simplifies project management and makes it easier to share and version control configurations.
128

13-
::: info
14-
The following documentation serves as a quick introduction on how to use the `robot.toml` file and will not cover all *Robot Framework* command line options. For a complete documentation of these options, please refer to the [Robot Framework User Guide](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html "Robot Framework User Guide").
15-
:::
9+
While the `robot.toml` file can be integrated with development environments like VS Code, its primary function is to centralize configuration for Robot Framework projects, streamlining the setup and maintenance process.
1610

17-
::: tip
18-
If you want to have code completion and such things for TOML files, install the **[Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml)** extension before attempting to work with `robot.toml`.
19-
:::
11+
This guide provides an overview of how to set up and use the `robot.toml` file to manage various aspects of your Robot Framework project.
2012

13+
---
2114

22-
## Settings configuration
15+
## About TOML Files
2316

24-
Using the `robot.toml` file, we can configure a wide range of settings for our project. The example below shows how we can setup the output directory, language and global project variables. In toml, `[variables]` is a tabular setting, meaning it can store multiple name-value pairs.
17+
TOML (Tom's Obvious, Minimal Language) is a file format designed to be easy to read and write due to its clear structure. TOML files use key-value pairs to define configuration settings, similar to JSON or YAML, but with a more human-friendly syntax. In the context of the `robot.toml` file, TOML is used to structure the configuration settings for your Robot Framework project, allowing for well-organized and readable project settings.
2518

26-
```toml
27-
output-dir = "output"
28-
languages = ["english"]
29-
30-
[variables]
31-
NAME = "Tim"
32-
AGE = "25"
33-
MAIL = "hotmail.de"
34-
```
35-
36-
You can access a full list of available setting by excetuting `robot --help` in the CLI.
37-
38-
39-
## Profiles
40-
41-
Profiles allow you to store multiple configurations, in an easily accessible way. This can be useful if for example you need a different set of configurations, for testing on multiple platforms. Profiles are easily expandable and can be easily shared between developers by simply providing them the robot.toml file.
42-
43-
44-
### Defining profiles
45-
46-
You can define a profile with `[profiles.YOUR_PROFILE_NAME]`. Follow it up with the settings that you want to configure for that particular profile. For tabular settings like `[variables]` you will need to create a separate entry using `[profiles.YOUR_PROFILE_NAME.variables]`. Your profiles will use any global configuration, that has not been defined within the profile. In example below, dev2 will use English as the language and *output* as the output directory.
47-
48-
```toml
49-
output-dir = "output"
50-
languages = ["english"]
51-
52-
[variables]
53-
NAME = "Tim"
54-
AGE = "25"
55-
MAIL = "hotmail.de"
56-
57-
[profiles.dev1]
58-
output-dir = "dev1output"
59-
languages = ["german"]
60-
61-
[profiles.dev1.variables]
62-
NAME = "Lisa"
63-
AGE = "32"
64-
MAIL = "web.de"
65-
66-
[profiles.dev2.variables]
67-
NAME = "Andrew"
68-
AGE = "19"
69-
MAIL = "gmail.com"
70-
71-
[profiles.dev3]
72-
output-dir = "dev3output"
73-
```
19+
For a full and detailed description of the TOML format, please refer to the official [TOML documentation](https://toml.io/en/).
7420

21+
---
7522

76-
### Overriding and extending settings
23+
## Configuring Settings
7724

78-
Tabular settings like `[variables]` can be either overridden or expanded. In the example below, dev1 and dev2 are overriding `[variables]`. Override will prevent dev1 and dev2 from using any of the values defined in lines 4-7. This means that dev2 will not use `NAME = "Tim"` defined in line 5 but instead whatever is defined in the relevant .robot files.
25+
The `robot.toml` file allows you to configure various settings for your project. Below is an example that demonstrates how to configure the output directory, language preferences, and some global project variables. In TOML, `[variables]` is used to store multiple name-value pairs.
7926

8027
```toml
8128
output-dir = "output"
82-
languages = ["english"]
29+
languages = ["en", "fi"]
8330

8431
[variables]
8532
NAME = "Tim"
8633
AGE = "25"
8734
MAIL = "hotmail.de"
88-
89-
[profiles.dev1.variables]
90-
NAME = "Lisa"
91-
AGE = "32"
92-
MAIL = "web.de"
93-
94-
[profiles.dev2.variables]
95-
AGE = "19"
96-
MAIL = "gmail.com"
9735
```
9836

99-
In order to change only selected values or add new ones, the 'extend-' prefix is needed. In the example below, dev2 will still use `NAME` and `AGE` defined in lines 2 and 3.
37+
The key concept is that for every option you can set via the command line in a `robot` call, there is a corresponding key in the `robot.toml` file. Options that can be specified multiple times, such as `--variable` or `--tag`, are stored as lists. To view all available options, you can run `robot --help` in the command line or refer
10038

101-
```toml
102-
[variables]
103-
NAME = "Tim"
104-
AGE = "25"
105-
MAIL = "hotmail.de"
106-
107-
[profiles.dev2.extend-variables]
108-
MAIL = "gmail.com"
109-
LOCATION = "Berlin"
110-
```
39+
For better readability, multi-word options are written with hyphens in the `robot.toml` file. For example, `--outputdir` becomes `output-dir`. In addition to standard command-line options, the `robot.toml` file offers additional configuration settings. To view the full list, you can run the `robotcode config info` command or consult the [Configuration Reference](../03_reference/config.md).
11140

11241

113-
### Inheriting and merging profiles
42+
## Profiles
11443

115-
Profiles can inherit from an already existing profile.
44+
Profiles in the `robot.toml` file allow you to store multiple configurations in an easily accessible way. This is particularly helpful when you need different settings for various testing environments, such as different platforms or testing conditions.
11645

117-
```toml
118-
[profiles.dev3]
119-
output-dir = "dev3output"
46+
### Example of Profiles
12047

121-
[profiles.inheritedFromDev3]
122-
inherits = ["dev3"]
123-
languages = ["german"]
124-
```
125-
126-
It is also possible to inherit from multiple profiles.
48+
Below is an example showing how to set up two profiles: `dev` and `prod`, each with distinct settings.
12749

12850
```toml
129-
[profiles.dev1]
130-
output-dir = "dev1output"
131-
languages = ["german"]
132-
133-
[profiles.dev1.variables]
134-
NAME = "Lisa"
135-
AGE = "32"
136-
MAIL = "web.de"
51+
[profiles.dev]
52+
output-dir = "output/dev"
53+
variables = { NAME = "Developer" }
13754

138-
[profiles.dev3]
139-
output-dir = "dev3output"
140-
141-
[profiles.dev1and3]
142-
inherits = ["dev1, dev3"]
55+
[profiles.prod]
56+
output-dir = "output/prod"
57+
variables = { NAME = "Production" }
14358
```
14459

145-
If a variable is present in multiple of the inherited profiles, the value of that variable will be the one, present in the last relevant inherited profile. In the example above, the value of `output-dir` for the dev1and2 profile, will be "dev3output".
146-
147-
148-
### Profile management
149-
150-
#### Selecting profiles
151-
152-
You can select a profile to work with, by entering "RobotCode: Select Configuration Profiles" in the command palette (ctrl+shift+p).
60+
### Inheriting Profiles
15361

154-
![Select Profile1](images/toml-profiles-command-selection.png)
155-
156-
Should you select more than one profile, a merged version of those profiles will be executed.
157-
Alternatively, you can select a profile to run or debug with, by clicking on the buttons, marked in the image below.
158-
159-
![Select Profile2](images/config_select_buttons.png)
160-
161-
Using this method however, does not allow you to select multiple profiles at once.
162-
163-
164-
#### Default profiles
165-
166-
It is possible to select a list of default profiles, using the `default-profiles` option. Those profiles will be selected by default, if no other profile has been selected for execution.
167-
Should you select more than one default profile, a merged version of those profiles will be executed.
62+
Profiles can also inherit settings from each other to reduce duplication. The `merge` keyword allows you to combine settings from multiple profiles.
16863

16964
```toml
170-
default-profiles = ["dev1", "dev2"]
171-
172-
[profiles.dev1.variables]
173-
NAME = "Lisa"
174-
AGE = "32"
175-
MAIL = "web.de"
176-
177-
[profiles.dev2.variables]
178-
AGE = "19"
179-
MAIL = "gmail.com"
180-
181-
[profiles.dev3.variables]
182-
MAIL = "hotmail.com"
65+
[profiles.shared]
66+
output-dir = "output/shared"
18367

68+
[profiles.dev]
69+
merge = ["shared"]
70+
variables = { NAME = "Dev" }
18471
```
18572

73+
### Hiding Profiles
18674

187-
#### Hiding profiles
188-
189-
If, for whatever reason, you wish for individual profiles to not be displayed as selectable options, you can hide them by using the `hidden` option.
75+
Profiles can be hidden using the `hidden` option or based on specific conditions through Python expressions.
19076

19177
```toml
192-
[profiles.dev1]
78+
[profiles.dev]
19379
hidden = true
194-
```
195-
196-
It is also possible to hide a profile based on user defined conditions, using python expressions.
19780

198-
```toml
199-
[profiles.dev1]
81+
[profiles.dev]
20082
hidden.if = "platform.system()=='Windows'"
20183
```
20284

203-
Hidden profiles can be still merged and inherited from.
204-
85+
### Enabling Profiles
20586

206-
#### Enabling profiles
207-
208-
Similar to hiding, profiles can be also disabled using the `enabled` option.
87+
Similarly, profiles can be enabled or disabled using the `enabled` option. This can also be based on user-defined conditions.
20988

21089
```toml
211-
[profiles.dev1]
90+
[profiles.dev]
21291
enabled = false
213-
```
21492

215-
It is also possible to enable or disable a profile based on user defined conditions, using python expressions.
216-
217-
```toml
218-
[profiles.dev1]
93+
[profiles.dev]
21994
enabled.if = "platform.system()=='Windows'"
22095
```
22196

22297
Disabled profiles cannot be merged or inherited from.
22398

99+
---
224100

225-
### Test Execution
226-
227-
In order to execute tests using the CLI, you will need to install the `robotcode-runner` pip package and add it to your requirements.txt.
228-
229-
230-
#### Executing tests
231-
232-
Here are some of the most common ways, to execute tests via the CLI.
233-
234-
235-
- `robotcode robot PATH`
236-
237-
Executes all tests (including in subfolders) within a given location. This command can be also executed with the command `robotcode robot`, if you add `paths = "TESTFILE_LOC"` to your robot.toml file.
238-
239-
- `robotcode robot -t "TEST_CASE_NAME"`
240-
241-
Executes the test case called `TEST_CASE_NAME`
101+
## Test Execution
242102

243-
- `robotcode -p PROFILE_NAME robot PATH`
103+
To execute tests using the CLI, ensure that the `robotcode-runner` pip package is installed and added to your `requirements.txt` file.
244104

245-
Executes all tests (including in subfolders) within a given location, with the selected profile.
105+
### Executing Tests
246106

247-
- `robotcode -p PROFILE_NAME_1 -p PROFILE_NAME_2 robot PATH`
107+
Here are some common ways to execute tests using the CLI:
248108

249-
Executes all tests (including in subfolders) within a given location, with a merged version the selected profiles.
109+
- Execute all tests within a location:
110+
```bash
111+
robotcode robot PATH
112+
```
113+
Alternatively, you can specify paths in the `robot.toml` file:
114+
```toml
115+
paths = "TESTFILE_LOC"
116+
```
250117

251-
- `robotcode -p PROFILE_NAME -v NAME:Carl robot PATH`
118+
- Execute a specific test case:
119+
```bash
120+
robotcode robot -t "TEST_CASE_NAME"
121+
```
252122

253-
Executes all tests (including in subfolders) within a given location. Changes the value of the variable `NAME` to `Carl`.
123+
- Execute tests with a specific profile:
124+
```bash
125+
robotcode -p PROFILE_NAME robot PATH
126+
```
254127

128+
- Merge and execute tests from multiple profiles:
129+
```bash
130+
robotcode -p PROFILE_NAME_1 -p PROFILE_NAME_2 robot PATH
131+
```
255132

256-
- `robotcode robot -i TAG_NAME`
133+
- Execute tests with a variable override:
134+
```bash
135+
robotcode -p PROFILE_NAME -v NAME:Carl robot PATH
136+
```
257137

258-
Executes all tests with a given tag. Tags can be assigned either globally in the settings or individually for each test case.
138+
- Execute tests by tag:
139+
```bash
140+
robotcode robot -i TAG_NAME
141+
```
259142

260-
<IMG src="images/tags_robot.PNG"/>
143+
Tags can be set globally or individually for each test case.

0 commit comments

Comments
 (0)