Debian Codegraph @

3rdparty/catch2/docs/command-line.md

raw symbols SCIP
1 <a id="top"></a>
2 # Command line
3
4 **Contents**<br>
5 [Specifying which tests to run](#specifying-which-tests-to-run)<br>
6 [Choosing a reporter to use](#choosing-a-reporter-to-use)<br>
7 [Breaking into the debugger](#breaking-into-the-debugger)<br>
8 [Showing results for successful tests](#showing-results-for-successful-tests)<br>
9 [Aborting after a certain number of failures](#aborting-after-a-certain-number-of-failures)<br>
10 [Listing available tests, tags or reporters](#listing-available-tests-tags-or-reporters)<br>
11 [Sending output to a file](#sending-output-to-a-file)<br>
12 [Naming a test run](#naming-a-test-run)<br>
13 [Eliding assertions expected to throw](#eliding-assertions-expected-to-throw)<br>
14 [Make whitespace visible](#make-whitespace-visible)<br>
15 [Warnings](#warnings)<br>
16 [Reporting timings](#reporting-timings)<br>
17 [Load test names to run from a file](#load-test-names-to-run-from-a-file)<br>
18 [Specify the order test cases are run](#specify-the-order-test-cases-are-run)<br>
19 [Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)<br>
20 [Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)<br>
21 [Wait for key before continuing](#wait-for-key-before-continuing)<br>
22 [Skip all benchmarks](#skip-all-benchmarks)<br>
23 [Specify the number of benchmark samples to collect](#specify-the-number-of-benchmark-samples-to-collect)<br>
24 [Specify the number of resamples for bootstrapping](#specify-the-number-of-resamples-for-bootstrapping)<br>
25 [Specify the confidence-interval for bootstrapping](#specify-the-confidence-interval-for-bootstrapping)<br>
26 [Disable statistical analysis of collected benchmark samples](#disable-statistical-analysis-of-collected-benchmark-samples)<br>
27 [Specify the amount of time in milliseconds spent on warming up each test](#specify-the-amount-of-time-in-milliseconds-spent-on-warming-up-each-test)<br>
28 [Usage](#usage)<br>
29 [Specify the section to run](#specify-the-section-to-run)<br>
30 [Filenames as tags](#filenames-as-tags)<br>
31 [Override output colouring](#override-output-colouring)<br>
32 [Test Sharding](#test-sharding)<br>
33 [Allow running the binary without tests](#allow-running-the-binary-without-tests)<br>
34 [Output verbosity](#output-verbosity)<br>
35
36 Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available.
37 Click one of the following links to take you straight to that option - or scroll on to browse the available options.
38
39 <a href="#specifying-which-tests-to-run"> ` <test-spec> ...`</a><br />
40 <a href="#usage"> ` -h, -?, --help`</a><br />
41 <a href="#showing-results-for-successful-tests"> ` -s, --success`</a><br />
42 <a href="#breaking-into-the-debugger"> ` -b, --break`</a><br />
43 <a href="#eliding-assertions-expected-to-throw"> ` -e, --nothrow`</a><br />
44 <a href="#invisibles"> ` -i, --invisibles`</a><br />
45 <a href="#sending-output-to-a-file"> ` -o, --out`</a><br />
46 <a href="#choosing-a-reporter-to-use"> ` -r, --reporter`</a><br />
47 <a href="#naming-a-test-run"> ` -n, --name`</a><br />
48 <a href="#aborting-after-a-certain-number-of-failures"> ` -a, --abort`</a><br />
49 <a href="#aborting-after-a-certain-number-of-failures"> ` -x, --abortx`</a><br />
50 <a href="#warnings"> ` -w, --warn`</a><br />
51 <a href="#reporting-timings"> ` -d, --durations`</a><br />
52 <a href="#input-file"> ` -f, --input-file`</a><br />
53 <a href="#run-section"> ` -c, --section`</a><br />
54 <a href="#filenames-as-tags"> ` -#, --filenames-as-tags`</a><br />
55
56
57 </br>
58
59 <a href="#listing-available-tests-tags-or-reporters"> ` --list-tests`</a><br />
60 <a href="#listing-available-tests-tags-or-reporters"> ` --list-tags`</a><br />
61 <a href="#listing-available-tests-tags-or-reporters"> ` --list-reporters`</a><br />
62 <a href="#listing-available-tests-tags-or-reporters"> ` --list-listeners`</a><br />
63 <a href="#order"> ` --order`</a><br />
64 <a href="#rng-seed"> ` --rng-seed`</a><br />
65 <a href="#libidentify"> ` --libidentify`</a><br />
66 <a href="#wait-for-keypress"> ` --wait-for-keypress`</a><br />
67 <a href="#skip-benchmarks"> ` --skip-benchmarks`</a><br />
68 <a href="#benchmark-samples"> ` --benchmark-samples`</a><br />
69 <a href="#benchmark-resamples"> ` --benchmark-resamples`</a><br />
70 <a href="#benchmark-confidence-interval"> ` --benchmark-confidence-interval`</a><br />
71 <a href="#benchmark-no-analysis"> ` --benchmark-no-analysis`</a><br />
72 <a href="#benchmark-warmup-time"> ` --benchmark-warmup-time`</a><br />
73 <a href="#colour-mode"> ` --colour-mode`</a><br />
74 <a href="#test-sharding"> ` --shard-count`</a><br />
75 <a href="#test-sharding"> ` --shard-index`</a><br />
76 <a href=#no-tests-override> ` --allow-running-no-tests`</a><br />
77 <a href=#output-verbosity> ` --verbosity`</a><br />
78
79 </br>
80
81
82
83 <a id="specifying-which-tests-to-run"></a>
84 ## Specifying which tests to run
85
86 <pre>&lt;test-spec> ...</pre>
87
88 Test cases, wildcarded test cases, tags and tag expressions are all passed directly as arguments. Tags are distinguished by being enclosed in square brackets.
89
90 If no test specs are supplied then all test cases, except "hidden" tests, are run.
91 A test is hidden by giving it any tag starting with (or just) a period (```.```) - or, in the deprecated case, tagged ```[hide]``` or given name starting with `'./'`. To specify hidden tests from the command line ```[.]``` or ```[hide]``` can be used *regardless of how they were declared*.
92
93 Specs must be enclosed in quotes if they contain spaces. If they do not contain spaces the quotes are optional.
94
95 Wildcards consist of the `*` character at the beginning and/or end of test case names and can substitute for any number of any characters (including none).
96
97 Test specs are case insensitive.
98
99 If a spec is prefixed with `exclude:` or the `~` character then the pattern matches an exclusion. This means that tests matching the pattern are excluded from the set - even if a prior inclusion spec included them. Subsequent inclusion specs will take precedence, however.
100 Inclusions and exclusions are evaluated in left-to-right order.
101
102 Test case examples:
103
104 ```
105 thisTestOnly Matches the test case called, 'thisTestOnly'
106 "this test only" Matches the test case called, 'this test only'
107 these* Matches all cases starting with 'these'
108 exclude:notThis Matches all tests except, 'notThis'
109 ~notThis Matches all tests except, 'notThis'
110 ~*private* Matches all tests except those that contain 'private'
111 a* ~ab* abc Matches all tests that start with 'a', except those that
112 start with 'ab', except 'abc', which is included
113 ~[tag1] Matches all tests except those tagged with '[tag1]'
114 -# [#somefile] Matches all tests from the file 'somefile.cpp'
115 ```
116
117 Names within square brackets are interpreted as tags.
118 A series of tags form an AND expression whereas a comma-separated sequence forms an OR expression. e.g.:
119
120 <pre>[one][two],[three]</pre>
121 This matches all tests tagged `[one]` and `[two]`, as well as all tests tagged `[three]`
122
123 Test names containing special characters, such as `,` or `[` can specify them on the command line using `\`.
124 `\` also escapes itself.
125
126 <a id="choosing-a-reporter-to-use"></a>
127 ## Choosing a reporter to use
128
129 <pre>-r, --reporter &lt;reporter[::key=value]*&gt;</pre>
130
131 Reporters are how the output from Catch2 (results of assertions, tests,
132 benchmarks and so on) is formatted and written out. The default reporter
133 is called the "Console" reporter and is intended to provide relatively
134 verbose and human-friendly output.
135
136 Reporters are also individually configurable. To pass configuration options
137 to the reporter, you append `::key=value` to the reporter specification
138 as many times as you want, e.g. `--reporter xml::out=someFile.xml`.
139
140 The keys must either be prefixed by "X", in which case they are not parsed
141 by Catch2 and are only passed down to the reporter, or one of options
142 hardcoded into Catch2. Currently there are only 2,
143 ["out"](#sending-output-to-a-file), and ["colour-mode"](#colour-mode).
144
145 _Note that the reporter might still check the X-prefixed options for
146 validity, and throw an error if they are wrong._
147
148 > Support for passing arguments to reporters through the `-r`, `--reporter` flag was introduced in Catch2 3.0.1
149
150 There are multiple built-in reporters, you can see what they do by using the
151 [`--list-reporters`](command-line.md#listing-available-tests-tags-or-reporters)
152 flag. If you need a reporter providing custom format outside of the already
153 provided ones, look at the ["write your own reporter" part of the reporter
154 documentation](reporters.md#writing-your-own-reporter).
155
156 This option may be passed multiple times to use multiple (different)
157 reporters at the same time. See the [reporter documentation](reporters.md#multiple-reporters)
158 for details on what the resulting behaviour is. Also note that at most one
159 reporter can be provided without the output-file part of reporter spec.
160 This reporter will use the "default" output destination, based on
161 the [`-o`, `--out`](#sending-output-to-a-file) option.
162
163 > Support for using multiple different reporters at the same time was [introduced](https://github.com/catchorg/Catch2/pull/2183) in Catch2 3.0.1
164
165
166 _Note: There is currently no way to escape `::` in the reporter spec,
167 and thus the reporter names, or configuration keys and values, cannot
168 contain `::`. As `::` in paths is relatively obscure (unlike ':'), we do
169 not consider this an issue._
170
171
172 <a id="breaking-into-the-debugger"></a>
173 ## Breaking into the debugger
174 <pre>-b, --break</pre>
175
176 Under most debuggers Catch2 is capable of automatically breaking on a test
177 failure. This allows the user to see the current state of the test during
178 failure.
179
180 <a id="showing-results-for-successful-tests"></a>
181 ## Showing results for successful tests
182 <pre>-s, --success</pre>
183
184 Usually you only want to see reporting for failed tests. Sometimes it's useful to see *all* the output (especially when you don't trust that that test you just added worked first time!).
185 To see successful, as well as failing, test results just pass this option. Note that each reporter may treat this option differently. The Junit reporter, for example, logs all results regardless.
186
187 <a id="aborting-after-a-certain-number-of-failures"></a>
188 ## Aborting after a certain number of failures
189 <pre>-a, --abort
190 -x, --abortx [&lt;failure threshold>]
191 </pre>
192
193 If a ```REQUIRE``` assertion fails the test case aborts, but subsequent test cases are still run.
194 If a ```CHECK``` assertion fails even the current test case is not aborted.
195
196 Sometimes this results in a flood of failure messages and you'd rather just see the first few. Specifying ```-a``` or ```--abort``` on its own will abort the whole test run on the first failed assertion of any kind. Use ```-x``` or ```--abortx``` followed by a number to abort after that number of assertion failures.
197
198 <a id="listing-available-tests-tags-or-reporters"></a>
199 ## Listing available tests, tags or reporters
200 ```
201 --list-tests
202 --list-tags
203 --list-reporters
204 --list-listeners
205 ```
206
207 > The `--list*` options became customizable through reporters in Catch2 3.0.1
208
209 > The `--list-listeners` option was added in Catch2 3.0.1
210
211 `--list-tests` lists all registered tests matching specified test spec.
212 Usually this listing also includes tags, and potentially also other
213 information, like source location, based on verbosity and reporter's design.
214
215 `--list-tags` lists all tags from registered tests matching specified test
216 spec. Usually this also includes number of tests cases they match and
217 similar information.
218
219 `--list-reporters` lists all available reporters and their descriptions.
220
221 `--list-listeners` lists all registered listeners and their descriptions.
222
223 The [`--verbosity` argument](#output-verbosity) modifies the level of detail provided by the default `--list*` options
224 as follows:
225
226 | Option | `normal` (default) | `quiet` | `high` |
227 |--------------------|---------------------------------|---------------------|-----------------------------------------|
228 | `--list-tests` | Test names and tags | Test names only | Same as `normal`, plus source code line |
229 | `--list-tags` | Tags and counts | Same as `normal` | Same as `normal` |
230 | `--list-reporters` | Reporter names and descriptions | Reporter names only | Same as `normal` |
231 | `--list-listeners` | Listener names and descriptions | Same as `normal` | Same as `normal` |
232
233 <a id="sending-output-to-a-file"></a>
234 ## Sending output to a file
235 <pre>-o, --out &lt;filename&gt;
236 </pre>
237
238 Use this option to send all output to a file, instead of stdout. You can
239 use `-` as the filename to explicitly send the output to stdout (this is
240 useful e.g. when using multiple reporters).
241
242 > Support for `-` as the filename was introduced in Catch2 3.0.1
243
244 Filenames starting with "%" (percent symbol) are reserved by Catch2 for
245 meta purposes, e.g. using `%debug` as the filename opens stream that
246 writes to platform specific debugging/logging mechanism.
247
248 Catch2 currently recognizes 3 meta streams:
249
250 * `%debug` - writes to platform specific debugging/logging output
251 * `%stdout` - writes to stdout
252 * `%stderr` - writes to stderr
253
254 > Support for `%stdout` and `%stderr` was introduced in Catch2 3.0.1
255
256
257 <a id="naming-a-test-run"></a>
258 ## Naming a test run
259 <pre>-n, --name &lt;name for test run></pre>
260
261 If a name is supplied it will be used by the reporter to provide an overall name for the test run. This can be useful if you are sending to a file, for example, and need to distinguish different test runs - either from different Catch executables or runs of the same executable with different options. If not supplied the name is defaulted to the name of the executable.
262
263 <a id="eliding-assertions-expected-to-throw"></a>
264 ## Eliding assertions expected to throw
265 <pre>-e, --nothrow</pre>
266
267 Skips all assertions that test that an exception is thrown, e.g. ```REQUIRE_THROWS```.
268
269 These can be a nuisance in certain debugging environments that may break when exceptions are thrown (while this is usually optional for handled exceptions, it can be useful to have enabled if you are trying to track down something unexpected).
270
271 Sometimes exceptions are expected outside of one of the assertions that tests for them (perhaps thrown and caught within the code-under-test). The whole test case can be skipped when using ```-e``` by marking it with the ```[!throws]``` tag.
272
273 When running with this option any throw checking assertions are skipped so as not to contribute additional noise. Be careful if this affects the behaviour of subsequent tests.
274
275 <a id="invisibles"></a>
276 ## Make whitespace visible
277 <pre>-i, --invisibles</pre>
278
279 If a string comparison fails due to differences in whitespace - especially leading or trailing whitespace - it can be hard to see what's going on.
280 This option transforms tabs and newline characters into ```\t``` and ```\n``` respectively when printing.
281
282 <a id="warnings"></a>
283 ## Warnings
284 <pre>-w, --warn &lt;warning name></pre>
285
286 You can think of Catch2's warnings as the equivalent of `-Werror` (`/WX`)
287 flag for C++ compilers. It turns some suspicious occurrences, like a section
288 without assertions, into errors. Because these might be intended, warnings
289 are not enabled by default, but user can opt in.
290
291 You can enable multiple warnings at the same time.
292
293 There are currently two warnings implemented:
294
295 ```
296 NoAssertions // Fail test case / leaf section if no assertions
297 // (e.g. `REQUIRE`) is encountered.
298 UnmatchedTestSpec // Fail test run if any of the CLI test specs did
299 // not match any tests.
300 ```
301
302 > `UnmatchedTestSpec` was introduced in Catch2 3.0.1.
303
304
305 <a id="reporting-timings"></a>
306 ## Reporting timings
307 <pre>-d, --durations &lt;yes/no></pre>
308
309 When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not.
310
311 <pre>-D, --min-duration &lt;value></pre>
312
313 > `--min-duration` was [introduced](https://github.com/catchorg/Catch2/pull/1910) in Catch2 2.13.0
314
315 When set, Catch will report the duration of each test case that took more
316 than &lt;value> seconds, in milliseconds. This option is overridden by both
317 `-d yes` and `-d no`, so that either all durations are reported, or none
318 are.
319
320
321 <a id="input-file"></a>
322 ## Load test names to run from a file
323 <pre>-f, --input-file &lt;filename></pre>
324
325 Provide the name of a file that contains a list of test case names,
326 one per line. Blank lines are skipped.
327
328 A useful way to generate an initial instance of this file is to combine
329 the [`--list-tests`](#listing-available-tests-tags-or-reporters) flag with
330 the [`--verbosity quiet`](#output-verbosity) option. You can also
331 use test specs to filter this list down to what you want first.
332
333
334 <a id="order"></a>
335 ## Specify the order test cases are run
336 <pre>--order &lt;decl|lex|rand&gt;</pre>
337
338 Test cases are ordered one of three ways:
339
340 ### decl
341 Declaration order (this is the default order if no --order argument is provided).
342 Tests in the same translation unit are sorted using their declaration orders,
343 different TUs are sorted in an implementation (linking) dependent order.
344
345
346 ### lex
347 Lexicographic order. Tests are sorted by their name, their tags are ignored.
348
349
350 ### rand
351
352 Randomly ordered. The order is dependent on Catch2's random seed (see
353 [`--rng-seed`](#rng-seed)), and is subset invariant. What this means
354 is that as long as the random seed is fixed, running only some tests
355 (e.g. via tag) does not change their relative order.
356
357 > The subset stability was introduced in Catch2 v2.12.0
358
359 Since the random order was made subset stable, we promise that given
360 the same random seed, the order of test cases will be the same across
361 different platforms, as long as the tests were compiled against identical
362 version of Catch2. We reserve the right to change the relative order
363 of tests cases between Catch2 versions, but it is unlikely to happen often.
364
365
366 <a id="rng-seed"></a>
367 ## Specify a seed for the Random Number Generator
368 <pre>--rng-seed &lt;'time'|'random-device'|number&gt;</pre>
369
370 Sets the seed for random number generators used by Catch2. These are used
371 e.g. to shuffle tests when user asks for tests to be in random order.
372
373 Using `time` as the argument asks Catch2 generate the seed through call
374 to `std::time(nullptr)`. This provides very weak randomness and multiple
375 runs of the binary can generate the same seed if they are started close
376 to each other.
377
378 Using `random-device` asks for `std::random_device` to be used instead.
379 If your implementation provides working `std::random_device`, it should
380 be preferred to using `time`. Catch2 uses `std::random_device` by default.
381
382
383 <a id="libidentify"></a>
384 ## Identify framework and version according to the libIdentify standard
385 <pre>--libidentify</pre>
386
387 See [The LibIdentify repo for more information and examples](https://github.com/janwilmans/LibIdentify).
388
389 <a id="wait-for-keypress"></a>
390 ## Wait for key before continuing
391 <pre>--wait-for-keypress &lt;never|start|exit|both&gt;</pre>
392
393 Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing -
394 either before running any tests, after running all tests - or both, depending on the argument.
395
396 <a id="skip-benchmarks"></a>
397 ## Skip all benchmarks
398 <pre>--skip-benchmarks</pre>
399
400 > [Introduced](https://github.com/catchorg/Catch2/issues/2408) in Catch2 3.0.1.
401
402 This flag tells Catch2 to skip running all benchmarks. Benchmarks in this
403 case mean code blocks in `BENCHMARK` and `BENCHMARK_ADVANCED` macros, not
404 test cases with the `[!benchmark]` tag.
405
406 <a id="benchmark-samples"></a>
407 ## Specify the number of benchmark samples to collect
408 <pre>--benchmark-samples &lt;# of samples&gt;</pre>
409
410 > [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0.
411
412 When running benchmarks a number of "samples" is collected. This is the base data for later statistical analysis.
413 Per sample a clock resolution dependent number of iterations of the user code is run, which is independent of the number of samples. Defaults to 100.
414
415 <a id="benchmark-resamples"></a>
416 ## Specify the number of resamples for bootstrapping
417 <pre>--benchmark-resamples &lt;# of resamples&gt;</pre>
418
419 > [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0.
420
421 After the measurements are performed, statistical [bootstrapping] is performed
422 on the samples. The number of resamples for that bootstrapping is configurable
423 but defaults to 100000. Due to the bootstrapping it is possible to give
424 estimates for the mean and standard deviation. The estimates come with a lower
425 bound and an upper bound, and the confidence interval (which is configurable but
426 defaults to 95%).
427
428 [bootstrapping]: http://en.wikipedia.org/wiki/Bootstrapping_%28statistics%29
429
430 <a id="benchmark-confidence-interval"></a>
431 ## Specify the confidence-interval for bootstrapping
432 <pre>--benchmark-confidence-interval &lt;confidence-interval&gt;</pre>
433
434 > [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0.
435
436 The confidence-interval is used for statistical bootstrapping on the samples to
437 calculate the upper and lower bounds of mean and standard deviation.
438 Must be between 0 and 1 and defaults to 0.95.
439
440 <a id="benchmark-no-analysis"></a>
441 ## Disable statistical analysis of collected benchmark samples
442 <pre>--benchmark-no-analysis</pre>
443
444 > [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0.
445
446 When this flag is specified no bootstrapping or any other statistical analysis is performed.
447 Instead the user code is only measured and the plain mean from the samples is reported.
448
449 <a id="benchmark-warmup-time"></a>
450 ## Specify the amount of time in milliseconds spent on warming up each test
451 <pre>--benchmark-warmup-time</pre>
452
453 > [Introduced](https://github.com/catchorg/Catch2/pull/1844) in Catch2 2.11.2.
454
455 Configure the amount of time spent warming up each test.
456
457 <a id="usage"></a>
458 ## Usage
459 <pre>-h, -?, --help</pre>
460
461 Prints the command line arguments to stdout
462
463
464 <a id="run-section"></a>
465 ## Specify the section to run
466 <pre>-c, --section &lt;section name&gt;</pre>
467
468 To limit execution to a specific section within a test case, use this option one or more times.
469 To narrow to sub-sections use multiple instances, where each subsequent instance specifies a deeper nesting level.
470
471 E.g. if you have:
472
473 <pre>
474 TEST_CASE( "Test" ) {
475 SECTION( "sa" ) {
476 SECTION( "sb" ) {
477 /*...*/
478 }
479 SECTION( "sc" ) {
480 /*...*/
481 }
482 }
483 SECTION( "sd" ) {
484 /*...*/
485 }
486 }
487 </pre>
488
489 Then you can run `sb` with:
490 <pre>./MyExe Test -c sa -c sb</pre>
491
492 Or run just `sd` with:
493 <pre>./MyExe Test -c sd</pre>
494
495 To run all of `sa`, including `sb` and `sc` use:
496 <pre>./MyExe Test -c sa</pre>
497
498 There are some limitations of this feature to be aware of:
499 - Code outside of sections being skipped will still be executed - e.g. any set-up code in the TEST_CASE before the
500 start of the first section.</br>
501 - At time of writing, wildcards are not supported in section names.
502 - If you specify a section without narrowing to a test case first then all test cases will be executed
503 (but only matching sections within them).
504
505
506 <a id="filenames-as-tags"></a>
507 ## Filenames as tags
508 <pre>-#, --filenames-as-tags</pre>
509
510 This option adds an extra tag to all test cases. The tag is `#` followed
511 by the unqualified filename the test case is defined in, with the _last_
512 extension stripped out.
513
514 For example, tests within the file `tests\SelfTest\UsageTests\BDD.tests.cpp`
515 will be given the `[#BDD.tests]` tag.
516
517
518 <a id="colour-mode"></a>
519 ## Override output colouring
520 <pre>--colour-mode &lt;ansi|win32|none|default&gt;</pre>
521
522 > The `--colour-mode` option replaced the old `--colour` option in Catch2 3.0.1
523
524
525 Catch2 support two different ways of colouring terminal output, and by
526 default it attempts to make a good guess on which implementation to use
527 (and whether to even use it, e.g. Catch2 tries to avoid writing colour
528 codes when writing the results into a file).
529
530 `--colour-mode` allows the user to explicitly select what happens.
531
532 * `--colour-mode ansi` tells Catch2 to always use ANSI colour codes, even
533 when writing to a file
534 * `--colour-mode win32` tells Catch2 to use colour implementation based
535 on Win32 terminal API
536 * `--colour-mode none` tells Catch2 to disable colours completely
537 * `--colour-mode default` lets Catch2 decide
538
539 `--colour-mode default` is the default setting.
540
541
542 <a id="test-sharding"></a>
543 ## Test Sharding
544 <pre>--shard-count <#number of shards>, --shard-index <#shard index to run></pre>
545
546 > [Introduced](https://github.com/catchorg/Catch2/pull/2257) in Catch2 3.0.1.
547
548 When `--shard-count <#number of shards>` is used, the tests to execute
549 will be split evenly in to the given number of sets, identified by indices
550 starting at 0. The tests in the set given by
551 `--shard-index <#shard index to run>` will be executed. The default shard
552 count is `1`, and the default index to run is `0`.
553
554 _Shard index must be less than number of shards. As the name suggests,
555 it is treated as an index of the shard to run._
556
557 Sharding is useful when you want to split test execution across multiple
558 processes, as is done with the [Bazel test sharding](https://docs.bazel.build/versions/main/test-encyclopedia.html#test-sharding).
559
560
561 <a id="no-tests-override"></a>
562 ## Allow running the binary without tests
563 <pre>--allow-running-no-tests</pre>
564
565 > Introduced in Catch2 3.0.1.
566
567 By default, Catch2 test binaries return non-0 exit code if no tests were run,
568 e.g. if the binary was compiled with no tests, the provided test spec matched no
569 tests, or all tests [were skipped at runtime](skipping-passing-failing.md#top). This flag
570 overrides that, so a test run with no tests still returns 0.
571
572 ## Output verbosity
573 ```
574 -v, --verbosity <quiet|normal|high>
575 ```
576
577 Changing verbosity might change how many details Catch2's reporters output.
578 However, you should consider changing the verbosity level as a _suggestion_.
579 Not all reporters support all verbosity levels, e.g. because the reporter's
580 format cannot meaningfully change. In that case, the verbosity level is
581 ignored.
582
583 Verbosity defaults to _normal_.
584
585
586 ---
587
588 [Home](Readme.md#top)