You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/02_get_started/configuration.md
+87-35
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,28 @@
1
1
# Configuration
2
2
3
3
## Introducing the `robot.toml` file
4
+
4
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
-
- providing a simpler way of defining project settings in one file
6
+
7
+
- providing a simpler way of defining settings for the Robot Framework project in one file
6
8
- creating a file that can be easily shared and uploaded to a git repository
7
9
- removing the need to create an argument file
8
10
- simplifying the command line execution
9
11
- allowing to define multiple, easily expandable, profiles
10
12
11
-
Please make sure that you have installed the **Even Better TOML** extension before attempting to work with `robot.toml`.
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
+
:::
16
+
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
+
:::
12
20
13
-
The following documentation serves as a quick introduction on how to use the `robot.toml` file and will cover only the essentials. For a complete documentation, please refer to the [Robot Framework User Guide](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html"Robot Framework User Guide").
14
21
15
22
## Settings configuration
23
+
16
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.
25
+
17
26
```toml
18
27
output-dir = "output"
19
28
languages = ["english"]
@@ -23,12 +32,19 @@ NAME = "Tim"
23
32
AGE = "25"
24
33
MAIL = "hotmail.de"
25
34
```
35
+
26
36
You can access a full list of available setting by excetuting `robot --help` in the CLI.
27
37
38
+
28
39
## Profiles
40
+
29
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
+
30
44
### Defining profiles
45
+
31
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
+
32
48
```toml
33
49
output-dir = "output"
34
50
languages = ["english"]
@@ -56,8 +72,11 @@ MAIL = "gmail.com"
56
72
output-dir = "dev3output"
57
73
```
58
74
75
+
59
76
### Overriding and extending settings
77
+
60
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.
79
+
61
80
```toml
62
81
output-dir = "output"
63
82
languages = ["english"]
@@ -76,7 +95,9 @@ MAIL = "web.de"
76
95
AGE = "19"
77
96
MAIL = "gmail.com"
78
97
```
98
+
79
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.
100
+
80
101
```toml
81
102
[variables]
82
103
NAME = "Tim"
@@ -88,8 +109,11 @@ MAIL = "gmail.com"
88
109
LOCATION = "Berlin"
89
110
```
90
111
112
+
91
113
### Inheriting and merging profiles
114
+
92
115
Profiles can inherit from an already existing profile.
116
+
93
117
```toml
94
118
[profiles.dev3]
95
119
output-dir = "dev3output"
@@ -98,6 +122,7 @@ output-dir = "dev3output"
98
122
inherits = ["dev3"]
99
123
languages = ["german"]
100
124
```
125
+
101
126
It is also possible to inherit from multiple profiles.
102
127
103
128
```toml
@@ -116,19 +141,31 @@ output-dir = "dev3output"
116
141
[profiles.dev1and3]
117
142
inherits = ["dev1, dev3"]
118
143
```
119
-
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".
144
+
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
+
120
148
### Profile management
121
149
122
150
#### Selecting profiles
151
+
123
152
You can select a profile to work with, by entering "RobotCode: Select Configuration Profiles" in the command palette (ctrl+shift+p).
Using this method however, does not allow you to select multiple profiles at once.
162
+
163
+
129
164
#### Default profiles
165
+
130
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.
131
167
Should you select more than one default profile, a merged version of those profiles will be executed.
168
+
132
169
```toml
133
170
default-profiles = ["dev1", "dev2"]
134
171
@@ -143,66 +180,81 @@ MAIL = "gmail.com"
143
180
144
181
[profiles.dev3.variables]
145
182
MAIL = "hotmail.com"
183
+
146
184
```
185
+
186
+
147
187
#### Hiding profiles
188
+
148
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.
190
+
149
191
```toml
150
192
[profiles.dev1]
151
193
hidden = true
152
194
```
195
+
153
196
It is also possible to hide a profile based on user defined conditions, using python expressions.
197
+
154
198
```toml
155
199
[profiles.dev1]
156
200
hidden.if = "platform.system()=='Windows'"
157
201
```
202
+
158
203
Hidden profiles can be still merged and inherited from.
204
+
205
+
159
206
#### Enabling profiles
207
+
160
208
Similar to hiding, profiles can be also disabled using the `enabled` option.
209
+
161
210
```toml
162
211
[profiles.dev1]
163
212
enabled = false
164
213
```
214
+
165
215
It is also possible to enable or disable a profile based on user defined conditions, using python expressions.
216
+
166
217
```toml
167
218
[profiles.dev1]
168
219
enabled.if = "platform.system()=='Windows'"
169
220
```
221
+
170
222
Disabled profiles cannot be merged or inherited from.
171
223
224
+
172
225
### Test Execution
173
-
It is possible to run tests from the CLI. TEXT ABOUT OTHER FORMS OF EXECUTION.
226
+
174
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.
175
228
229
+
176
230
#### Executing tests
231
+
177
232
Here are some of the most common ways, to execute tests via the CLI.
178
233
179
-
<detailsclosed>
180
-
<summary>robotcode robot PATH</summary>
181
-
Executes all tests (including in subfolders) within a given location. This command can be also executed with the command <spanstyle="color:lightblue">robotcode robot</span> robot, if you add <spanstyle="color:lightblue">paths = "TESTFILE_LOC"</span> to your robot.toml file.
Executes all tests (including in subfolders) within a given location. Changes the value of the variable <spanstyle="color:lightblue">NAME</span> to <spanstyle="color:lightblue">Carl</span>.
202
-
</details>
203
-
204
-
<detailsclosed>
205
-
<summary>robotcode robot -i TAG_NAME</summary>
206
-
Executes all tests with a given tag. Tags can be assigned either globally in the settings or individually for each test case.
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`
242
+
243
+
-`robotcode -p PROFILE_NAME robot PATH`
244
+
245
+
Executes all tests (including in subfolders) within a given location, with the selected profile.
0 commit comments