]>
Commit | Line | Data |
---|---|---|
d3081fa2 | 1 | # Notes |
8baf865c GA |
2 | The sources in this directory are unit test cases. Boost includes a |
3 | unit testing framework, and since bitcoin already uses boost, it makes | |
4 | sense to simply use this framework rather than require developers to | |
5 | configure some other framework (we want as few impediments to creating | |
6 | unit tests as possible). | |
7 | ||
8 | The build system is setup to compile an executable called "test_bitcoin" | |
9 | that runs all of the unit tests. The main source file is called | |
10 | test_bitcoin.cpp, which simply includes other files that contain the | |
11 | actual unit tests (outside of a couple required preprocessor | |
12 | directives). The pattern is to create one test file for each class or | |
13 | source file for which you want to create unit tests. The file naming | |
14 | convention is "<source_filename>_tests.cpp" and such files should wrap | |
15 | their tests in a test suite called "<source_filename>_tests". For an | |
16 | examples of this pattern, examine uint160_tests.cpp and | |
17 | uint256_tests.cpp. | |
18 | ||
e42bf16a EL |
19 | Add the source files to /src/Makefile.test.include to add them to the build. |
20 | ||
8baf865c GA |
21 | For further reading, I found the following website to be helpful in |
22 | explaining how the boost unit test framework works: | |
5c27f124 | 23 | [http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/](http://www.alittlemadness.com/2009/03/31/c-unit-testing-with-boosttest/). |