@@ -10,14 +10,19 @@ The build system is set up to compile an executable called `test_bitcoin`
1010that runs all of the unit tests. The main source file for the test library is found in
1111` util/setup_common.cpp ` .
1212
13+ The examples in this document assume the build directory is named
14+ ` build ` . You'll need to adapt them if you named it differently.
15+
1316### Compiling/running unit tests
1417
1518Unit tests will be automatically compiled if dependencies were met
1619during the generation of the Bitcoin Core build system
1720and tests weren't explicitly disabled.
1821
19- Assuming the build directory is named ` build ` , the unit tests can be run
20- with ` ctest --test-dir build ` , which includes unit tests from subtrees.
22+ The unit tests can be run with ` ctest --test-dir build ` , which includes unit
23+ tests from subtrees.
24+
25+ Run ` test_bitcoin --list_content ` for the full list of tests.
2126
2227To run the unit tests manually, launch ` build/src/test/test_bitcoin ` . To recompile
2328after a test file was modified, run ` cmake --build build ` and then run the test again. If you
@@ -35,34 +40,45 @@ the `src/qt/test/test_main.cpp` file.
3540
3641### Running individual tests
3742
38- ` test_bitcoin ` accepts the command line arguments from the boost framework.
39- For example, to run just the ` getarg_tests ` suite of tests:
43+ The ` test_bitcoin ` runner accepts command line arguments from the Boost
44+ framework. To see the list of arguments that may be passed, run:
45+
46+ ```
47+ test_bitcoin --help
48+ ```
49+
50+ For example, to run only the tests in the ` getarg_tests ` file, with full logging:
4051
4152``` bash
4253build/src/test/test_bitcoin --log_level=all --run_test=getarg_tests
4354```
4455
45- ` log_level ` controls the verbosity of the test framework, which logs when a
46- test case is entered, for example.
56+ or
4757
48- ` test_bitcoin ` also accepts some of the command line arguments accepted by
49- ` bitcoind ` . Use ` -- ` to separate these sets of arguments:
58+ ``` bash
59+ build/src/test/test_bitcoin -l all -t getarg_tests
60+ ```
61+
62+ or to run only the doubledash test in ` getarg_tests `
5063
5164``` bash
52- build/src/test/test_bitcoin --log_level=all -- run_test=getarg_tests -- -printtoconsole=1
65+ build/src/test/test_bitcoin --run_test=getarg_tests/doubledash
5366```
5467
55- The ` -printtoconsole=1 ` after the two dashes sends debug logging, which
56- normally goes only to ` debug.log ` within the data directory, also to the
57- standard terminal output.
68+ The ` --log_level= ` (or ` -l ` ) argument controls the verbosity of the test output.
5869
59- ... or to run just the doubledash test:
70+ The ` test_bitcoin ` runner also accepts some of the command line arguments accepted by
71+ ` bitcoind ` . Use ` -- ` to separate these sets of arguments:
6072
6173``` bash
62- build/src/test/test_bitcoin --run_test=getarg_tests/doubledash
74+ build/src/test/test_bitcoin --log_level=all -- run_test=getarg_tests -- -printtoconsole=1
6375```
6476
65- ` test_bitcoin ` creates a temporary working (data) directory with a randomly
77+ The ` -printtoconsole=1 ` after the two dashes sends debug logging, which
78+ normally goes only to ` debug.log ` within the data directory, to the
79+ standard terminal output as well.
80+
81+ Running ` test_bitcoin ` creates a temporary working (data) directory with a randomly
6682generated pathname within ` test_common bitcoin/ ` , which in turn is within
6783the system's temporary directory (see
6884[ ` temp_directory_path ` ] ( https://en.cppreference.com/w/cpp/filesystem/temp_directory_path ) ).
@@ -97,8 +113,6 @@ If you run an entire test suite, such as `--run_test=getarg_tests`, or all the t
97113(by not specifying ` --run_test ` ), a separate directory
98114will be created for each individual test.
99115
100- Run ` test_bitcoin --help ` for the full list of tests.
101-
102116### Adding test cases
103117
104118To add a new unit test file to our test suite, you need
0 commit comments