Changeset View
Changeset View
Standalone View
Standalone View
doc/unit-tests.md
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | ... or to run just the doubledash test: | ||||
test_bitcoin --run_test=getarg_tests/doubledash | test_bitcoin --run_test=getarg_tests/doubledash | ||||
Run `test_bitcoin --help` for the full list. | Run `test_bitcoin --help` for the full list. | ||||
### Note on adding test cases | ### Note on adding test cases | ||||
The build system is setup to compile an executable called `test_bitcoin` | The build system is setup to compile an executable called `test_bitcoin` | ||||
that runs all of the unit tests. The main source file is called | that runs all of the unit tests. The main source file for the test library | ||||
setup_common.cpp. To add a new unit test file to our test suite you need | is found in `util/setup_common.cpp`. To add a new unit test file to our | ||||
to add the file to `src/test/CMakeLists.txt`. The pattern is to create | test suite you need to add the file to `src/test/CMakeLists.txt`. | ||||
one test file for each class or source file for which you want to create | The pattern is to create one test file for each class or source file for | ||||
unit tests. The file naming convention is `<source_filename>_tests.cpp` | which you want to create unit tests. The file naming convention is | ||||
and such files should wrap their tests in a test suite | `<source_filename>_tests.cpp` and such files should wrap their tests in | ||||
called `<source_filename>_tests`. For an example of this pattern, | a test suite called `<source_filename>_tests`. For an example of this pattern, | ||||
examine `uint256_tests.cpp`. | examine `uint256_tests.cpp`. | ||||
For further reading, I found the following website to be helpful in | For further reading, I found the following website to be helpful in | ||||
explaining how the boost unit test framework works: | explaining how the boost unit test framework works: | ||||
[https://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-test-part-1/](https://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-test-part-1/) | [https://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-test-part-1/](https://legalizeadulthood.wordpress.com/2009/07/04/c-unit-tests-with-boost-test-part-1/) | ||||
### Debugging unit tests | ### Debugging unit tests | ||||
Show All 18 Lines |