@@ -54,49 +54,98 @@ Robot Framework offers several command line options for selecting
54
54
which test cases to execute. The same options work also when `executing
55
55
tasks `_ and when post-processing outputs with Rebot _.
56
56
57
- By test suite and test case names
58
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
-
60
- Test suites and test cases can be selected by their names with the command
61
- line options :option: `--suite (-s) ` and :option: `--test (-t) `,
62
- respectively. Both of these options can be used several times to
63
- select several test suites or cases. Arguments to these options are
64
- case- and space-insensitive, and there can also be `simple
65
- patterns `_ matching multiple names. If both the :option: `--suite ` and
66
- :option: `--test ` options are used, only test cases in matching suites
67
- with matching names are selected.
57
+ By test names
58
+ ~~~~~~~~~~~~~
68
59
69
- ::
60
+ The easiest way to select only some tests to be run is using the
61
+ :option: `--test (-t) ` option. As the name implies, it can be used for
62
+ selecting tests by their names. Given names are case, space and underscore
63
+ insensitive and they also support `simple patterns `_. The option can be
64
+ used multiple times to match multiple tests::
70
65
71
- --test Example
72
- --test mytest --test yourtest
73
- --test example*
74
- --test mysuite.mytest
75
- --test *.suite.mytest
76
- --suite example-??
77
- --suite mysuite --test mytest --test your*
78
-
79
- Using the :option: `--suite ` option is more or less the same as executing only
80
- the appropriate test case file or directory. One major benefit is the
81
- possibility to select the suite based on its parent suite. The syntax
82
- for this is specifying both the parent and child suite names separated
83
- with a dot. In this case, the possible setup and teardown of the parent
84
- suite are executed.
66
+ --test Example # Match only tests with name 'Example'.
67
+ --test example* # Match tests starting with 'example'.
68
+ --test first --test second # Match tests with name 'first' or 'second'.
85
69
86
- ::
70
+ To pinpoint a test more precisely, it is possible to prefix the test name
71
+ with a suite name::
72
+
73
+ --test mysuite.mytest # Match test 'mytest' in suite 'mysuite'.
74
+ --test root.sub.test # Match test 'test' in suite 'sub' in suite 'root'.
75
+ --test *.sub.test # Match test 'test' in suite 'sub' anywhere.
87
76
88
- --suite parent.child
89
- --suite myhouse.myhousemusic --test jack*
77
+ Notice that when the given name includes a suite name, it must match the whole
78
+ suite name starting from the root suite. Using a wildcard as in the last example
79
+ above allows matching suites anywhere.
90
80
91
- Selecting individual test cases with the :option: `--test ` option is very
92
- practical when creating test cases, but quite limited when running tests
93
- automatically. The :option: `--suite ` option can be useful in that
94
- case, but in general, selecting test cases by tag names is more
95
- flexible.
81
+ Using the :option: `--test ` option is convenient when only a few tests needs
82
+ to be selected. A common use case is running just the test that is currently
83
+ being worked on. If a bigger number of tests needs to be selected,
84
+ it is typically easier to select them `by suite names `_ or `by tag names `_.
96
85
97
86
When `executing tasks `_, it is possible to use the :option: `--task ` option
98
87
as an alias for :option: `--test `.
99
88
89
+ By suite names
90
+ ~~~~~~~~~~~~~~
91
+
92
+ Tests can be selected also by suite names with the :option: `--suite (-s) `
93
+ option that selects all tests in matching suites. Similarly
94
+ as with :option: `--test `, given names are case, space and underscore
95
+ insensitive and support `simple patterns `_. To pinpoint a suite
96
+ more precisely, it is possible to prefix the name with the parent suite
97
+ name::
98
+
99
+ --suite Example # Match only suites with name 'Example'.
100
+ --suite example* # Match suites starting with 'example'.
101
+ --suite first --suite second # Match suites with name 'first' or 'second'.
102
+ --suite parent.child # Match suite 'child' in suite 'parent'.
103
+
104
+ Unlike with :option: `--test `, the name does not need to match the whole
105
+ suite name, starting from the root suite, when the name contains a parent
106
+ suite name. This behavior `will be changed `__ in the future and should not be relied
107
+ upon. It is recommended to use the full name like `--suite root.parent.child `
108
+ or `--suite *.parent.child `.
109
+
110
+ If both :option: `--suite ` and :option: `--test ` options are used, only the
111
+ specified tests in specified suites are selected::
112
+
113
+ --suite mysuite --test mytest # Match test 'mytest' if its inside suite 'mysuite'.
114
+
115
+ Also this behavior `is likely to change `__ in the future and the above changed to mean
116
+ selecting all tests in suite `mysuite ` in addition to all tests with name `mytest `.
117
+ A more reliable way to select a test in a suite is using `--test *.mysuite.mytest `
118
+ or `--test *.mysuite.*.mytest ` depending on should the test be directly inside
119
+ the suite or not.
120
+
121
+ Using the :option: `--suite ` option is more or less the same as executing
122
+ the appropriate suite file or directory directly. The main difference is
123
+ that if a file or directory is run directly, possible suite setups and teardowns
124
+ on higher level are not executed::
125
+
126
+ # Root suite is 'Tests' and its possible setup and teardown are run.
127
+ robot --suite example path/to/tests
128
+
129
+ # Root suite is 'Example' and possible higher level setups and teardowns are ignored.
130
+ robot path/to/tests/example.robot
131
+
132
+ When using the :option: `--suite ` option, Robot Framework does not parse
133
+ files that do not match the given suite name. For example, when using
134
+ `--suite example `, only files that have a name :file: `example.robot ` or are in
135
+ a directory :file: `example ` are parsed. This is done for performance reasons
136
+ to avoid the parsing overhead with larger directory structures. Unfortunately
137
+ this approach does not work well with the new :setting: `Name ` setting that can
138
+ be used for setting a custom `suite name `_. In practice the new setting and
139
+ the :option: `--suite ` option are incompatible. This will be changed in Robot
140
+ Framework 7.0 so that `files are not excluded `__ when using the :option: `--suite `
141
+ option. The plan is to add an explicit option for `selecting files to parse `__
142
+ before that.
143
+
144
+ __ https://github.com/robotframework/robotframework/issues/4720
145
+ __ https://github.com/robotframework/robotframework/issues/4721
146
+ __ https://github.com/robotframework/robotframework/issues/4688
147
+ __ https://github.com/robotframework/robotframework/issues/4687
148
+
100
149
By tag names
101
150
~~~~~~~~~~~~
102
151
0 commit comments