onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <title>commandline</title> |
| 4 | <xmp theme="united" style="display:none;"> |
| 5 | |
| 6 | ## Command line |
| 7 | |
onqtam | 1435c01 | 2016-09-21 15:29:11 +0300 | [diff] [blame] | 8 | **doctest** works quite nicely without any command line options at all - but for more control a bunch are available. |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 9 | |
| 10 | **Query flags** - after the result is printed the program quits without executing any test cases (and if the framework is integrated into a client codebase which [**supplies it's own ```main()``` entry point**](main.html) - the program should check the result of ```doctest::Context::shouldExit()``` after calling ```doctest::Context::run()``` and should exit - this is left up to the user). |
| 11 | |
| 12 | **Int/String options** - they require a value after the ```=``` sign - without spaces! For example: ```--order-by=rand```. |
| 13 | |
| 14 | **Bool options** - they expect ```1```/```yes```/```on```/```true``` or ```0```/```no```/```off```/```false``` after the ```=``` sign - but they can also be used like flags and the ```=value``` part can be skipped - then ```true``` is assumed. |
| 15 | |
| 16 | **Filters** use wildcards for matching values - where ```*``` means "match any sequence" and ```?``` means "match any one character". |
| 17 | To pass a pattern with an interval use ```""``` like this: ```--test-case="*no sound*,vaguely named test number ?"```. |
| 18 | |
onqtam | 1435c01 | 2016-09-21 15:29:11 +0300 | [diff] [blame] | 19 | All the options can also be set with code (defaults/overrides) if the user [**supplies the ```main()``` function**](main.html). |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 20 | |
| 21 | | Query Flags | Description | |
| 22 | |:------------|-------------| |
| 23 | | ```-?``` ```--help``` ```-h``` | Prints a help message listing all these flags/options | |
| 24 | | ```-v``` ```--version``` | Prints the version of the **doctest** framework | |
| 25 | | ```-c``` ```--count``` | Prints the number of test cases matching the current filters (see below) | |
| 26 | | ```-ltc``` ```--list-test-cases``` | Lists all test cases by name which match the current filters (see below) | |
| 27 | | ```-lts``` ```--list-test-suites``` | Lists all test suites by name which have at least one test case matching the current filters (see below) | |
| 28 | | **Int/String Options** | <hr> | |
| 29 | | ```-tc``` ```--test-case=<filters>``` | Filters test cases based on their name. By default all test cases match but if a value is given to this filter like ```--test-case=*math*,*sound*``` then only test cases who match atleast one of the patterns in the comma-separated list with wildcards will get executed/counted/listed | |
| 30 | | ```-tce``` ```--test-case-exclude=<filters>``` | Same as the ```-test-case=<filters>``` option but if any of the patterns in the comma-separated list of values matches - then the test case is skipped | |
| 31 | | ```-sf``` ```--source-file=<filters>``` | Same as ```--test-case=<filters>``` but filters based on the file in which test cases are written | |
| 32 | | ```-sfe``` ```--source-file-exclude=<filters>``` | Same as ```--test-case-exclude=<filters>``` but filters based on the file in which test cases are written | |
| 33 | | ```-ts``` ```--test-suite=<filters>``` | Same as ```--test-case=<filters>``` but filters based on the test suite in which test cases are in | |
| 34 | | ```-tse``` ```--test-suite-exclude=<filters>``` | Same as ```--test-case-exclude=<filters>``` but filters based on the test suite in which test cases are in | |
| 35 | | ```-ob``` ```--order-by=<string>``` | Test cases will be sorted before being executed either by **the file in which they are** / **the test suite they are in** / **their name** / **random**. The possible values of ```<string>``` are ```file```/```suite```/```name```/```rand```. The default is ```file``` | |
| 36 | | ```-rs``` ```--rand-seed=<int>``` | The seed for random ordering | |
| 37 | | ```-f``` ```--first=<int>``` | The **first** test case to execute which passes the current filters - for range-based execution - see [**the example**](../../examples/range_based_execution/) (the **run.py** script) | |
| 38 | | ```-l``` ```--last=<int>``` | The **last** test case to execute which passes the current filters - for range-based execution - see [**the example**](../../examples/range_based_execution/) (the **run.py** script) | |
| 39 | | ```-aa``` ```--abort-after=<int>``` | The testing framework will stop executing test cases/assertions after this many failed assertions. The default is 0 which means don't stop at all | |
| 40 | | **Bool Options** | <hr> | |
| 41 | | ```-s``` ```--success=<bool>``` | To include successful assertions in the output | |
| 42 | | ```-cs``` ```--case-sensitive=<bool>``` | Filters being treated as case sensitive | |
| 43 | | ```-e``` ```--exit=<bool>``` | Exits after the tests finish - this is meaningful only when the client has [**provided the ```main()``` entry point**](main.html) - the program should check ```doctest::Context::shouldExit()``` after calling ```doctest::Context::run()``` and should exit - this is left up to the user. The idea is to be able to execute just the tests in a client program and to not continue with it's execution | |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 44 | | ```-nt``` ```--no-throw=<bool>``` | Skips [**exceptions-related assertion**](assertions.html#exceptions) checks | |
| 45 | | ```-ne``` ```--no-exitcode=<bool>``` | Always returns a successful exit code - even if a test case has failed | |
| 46 | | ```-nr``` ```--no-run=<bool>``` | Skips all runtime **doctest** operations (except the test registering which happens before the program enters ```main()```). This is useful if the testing framework is integrated into a client codebase which has [**provided the ```main()``` entry point**](main.html) and the user wants to skip running the tests and just use the program | |
| 47 | | ```-nc``` ```--no-colors=<bool>``` | Disables colors in the output | |
| 48 | | ```-nb``` ```--no-breaks=<bool>``` | Disables breakpoints in debuggers when an assertion fails | |
| 49 | | ```-npf``` ```--no-path-filenames=<bool>``` | Paths are removed from the output when a filename is printed - useful if you want the same output from the testing framework on different environments | |
| 50 | | | | |
| 51 | |
onqtam | 1435c01 | 2016-09-21 15:29:11 +0300 | [diff] [blame] | 52 | All the flags/options also come with a prefixed version (with ```--dt-``` at the front) - for example ```--version``` can be used also with ```--dt-version``` or ```--dt-v```. |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 53 | |
onqtam | 1435c01 | 2016-09-21 15:29:11 +0300 | [diff] [blame] | 54 | All the unprefixed versions listed here can be disabled with the [**```DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS```**](configuration.html#doctest_config_no_unprefixed_options) define. |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 55 | |
onqtam | 1435c01 | 2016-09-21 15:29:11 +0300 | [diff] [blame] | 56 | This is done for easy interoperability with client command line option handling when the testing framework is integrated within a client codebase - all **doctest** related flags/options can be prefixed so there are no clashes and so that the user can exclude everything starting with ```--dt-``` from their option parsing. |
| 57 | |
| 58 | If there isn't an option to exclude everything starting with ```--dt-``` then the [**removing_doctest_options**](../../examples/removing_doctest_options/) example might help. |
onqtam | 8126b56 | 2016-05-27 17:01:15 +0300 | [diff] [blame] | 59 | |
| 60 | --------------- |
| 61 | |
| 62 | [Home](readme.html#reference) |
| 63 | |
| 64 | |
| 65 | </xmp> |
| 66 | <script src="strapdown.js/strapdown.js"></script> |
| 67 | </html> |