You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long. 2.3KB

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