Add first unittests #497

Manually merged
johnny9 merged 7 commits from unittest into qt6 2026-02-25 22:05:53 +00:00 AGit
johnny9 commented 2025-08-28 15:43:00 +00:00 (Migrated from github.com)

This adds an initial unittest against the bitcoinamount module. This is the simplest c++ module to test so its an easy first target. I think the Qt test framework is the best fit for the project and eventually I imagine GMock will be needed to mock out portions of bitcoin interfaces as well as more complex modules get tested. These changes update the CMake definitions and add a BUILD_APP_TESTS option to toggle building of the unittests.

A new ci workflow is added as well to run the unittests (and eventually other testing that we have).

This adds an initial unittest against the bitcoinamount module. This is the simplest c++ module to test so its an easy first target. I think the Qt test framework is the best fit for the project and eventually I imagine GMock will be needed to mock out portions of bitcoin interfaces as well as more complex modules get tested. These changes update the CMake definitions and add a BUILD_APP_TESTS option to toggle building of the unittests. A new ci workflow is added as well to run the unittests (and eventually other testing that we have).
jarolrod commented 2026-02-16 03:58:11 +00:00 (Migrated from github.com)

ACK 16e86dddbd

@hebasto can you give your opinion on the CMAKE toggle here

ACK 16e86dddbdc069d126a5f2131f181cee05c80171 @hebasto can you give your opinion on the CMAKE toggle here
johnny9 commented 2026-02-25 14:38:58 +00:00 (Migrated from github.com)

Squashed the ci fixes

Squashed the ci fixes
johnny9 commented 2026-02-25 14:39:33 +00:00 (Migrated from github.com)

I introduced a small qml test as well. We will use Qtest to test the c++ modules as well as the qml

I introduced a small qml test as well. We will use Qtest to test the c++ modules as well as the qml
D33r-Gee commented 2026-02-25 17:07:24 +00:00 (Migrated from github.com)

tACK 236141e on WSL Unbuntu 24.04.3

The binaries build without issues and the test returned "Passed"

Also the additions of the qml modules dependencies is helpful

ctest --test-dir build --output-on-failure

 Start 1: bitcoinqml_unit_tests
1/2 Test #1: bitcoinqml_unit_tests ............   Passed    0.04 sec
    Start 2: bitcoinqml_qmltests
2/2 Test #2: bitcoinqml_qmltests ..............   Passed    0.04 sec
tACK [236141e](https://github.com/bitcoin-core/gui-qml/commit/236141ea2db490114cd25976cc442be733467f06) on WSL Unbuntu 24.04.3 The binaries build without issues and the test returned "Passed" Also the additions of the qml modules dependencies is helpful ``` ctest --test-dir build --output-on-failure Start 1: bitcoinqml_unit_tests 1/2 Test #1: bitcoinqml_unit_tests ............ Passed 0.04 sec Start 2: bitcoinqml_qmltests 2/2 Test #2: bitcoinqml_qmltests .............. Passed 0.04 sec ```
hebasto (Migrated from github.com) reviewed 2026-02-25 21:59:42 +00:00
Lines 134-135
hebasto (Migrated from github.com) commented 2026-02-25 21:59:42 +00:00

From enable_testing docs:

This command is also automatically invoked when the CTest module is included, except if the BUILD_TESTING option is turned off.

  include(CTest)
From `enable_testing` [docs](https://cmake.org/cmake/help/latest/command/enable_testing.html): > This command is also automatically invoked when the [CTest](https://cmake.org/cmake/help/latest/module/CTest.html#module:CTest) module is included, except if the [BUILD_TESTING](https://cmake.org/cmake/help/latest/variable/BUILD_TESTING.html#variable:BUILD_TESTING) option is turned off. ```suggestion include(CTest) ```
Sign in to join this conversation.
No description provided.