Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / src / test / README.md
blob01da32109b168843d5d942a7d274ceaad6a27d35
1 ### Compiling/running unit tests
3 Unit tests will be automatically compiled if dependencies were met in `./configure`
4 and tests weren't explicitly disabled.
6 After configuring, they can be run with `make check`.
8 To run the bitcoind tests manually, launch `src/test/test_bitcoin`. To recompile
9 after a test file was modified, run `make` and then run the test again. If you
10 modify a non-test file, use `make -C src/test` to recompile only what's needed
11 to run the bitcoind tests.
13 To add more bitcoind tests, add `BOOST_AUTO_TEST_CASE` functions to the existing
14 .cpp files in the `test/` directory or add new .cpp files that
15 implement new BOOST_AUTO_TEST_SUITE sections.
17 To run the bitcoin-qt tests manually, launch `src/qt/test/test_bitcoin-qt`
19 To add more bitcoin-qt tests, add them to the `src/qt/test/` directory and
20 the `src/qt/test/test_main.cpp` file.
22 ### Running individual tests
24 test_bitcoin has some built-in command-line arguments; for
25 example, to run just the getarg_tests verbosely:
27     test_bitcoin --log_level=all --run_test=getarg_tests
29 ... or to run just the doubledash test:
31     test_bitcoin --run_test=getarg_tests/doubledash
33 Run `test_bitcoin --help` for the full list.
35 ### Note on adding test cases
37 The sources in this directory are unit test cases.  Boost includes a
38 unit testing framework, and since bitcoin already uses boost, it makes
39 sense to simply use this framework rather than require developers to
40 configure some other framework (we want as few impediments to creating
41 unit tests as possible).
43 The build system is setup to compile an executable called `test_bitcoin`
44 that runs all of the unit tests.  The main source file is called
45 test_bitcoin.cpp. To add a new unit test file to our test suite you need 
46 to add the file to `src/Makefile.test.include`. The pattern is to create 
47 one test file for each class or source file for which you want to create 
48 unit tests.  The file naming convention is `<source_filename>_tests.cpp` 
49 and such files should wrap their tests in a test suite 
50 called `<source_filename>_tests`. For an example of this pattern, 
51 examine `uint256_tests.cpp`.
53 For further reading, I found the following website to be helpful in
54 explaining how the boost unit test framework works:
55 [http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/](http://archive.is/dRBGf).