Skip to content

test: remove gMock dependency - #802

Open
johnny9 wants to merge 3 commits into
bitcoin-core:qt6from
johnny9:remove-gmock-dependency
Open

test: remove gMock dependency#802
johnny9 wants to merge 3 commits into
bitcoin-core:qt6from
johnny9:remove-gmock-dependency

Conversation

@johnny9

@johnny9 johnny9 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace gMock with small handwritten Node and Wallet test doubles
  • build app tests by default for regular qt6 builds
  • build and run the C++ and QML tests in CI

Tests

  • Bitcoin Core CI lint
  • system and depends builds
  • C++ and QML app tests

Closes #753
Closes #754
Closes #778

@johnny9
johnny9 marked this pull request as ready for review July 19, 2026 16:09
@hebasto

hebasto commented Jul 19, 2026

Copy link
Copy Markdown
Member

There seems to be a conflict with the merged #796. Could you rebase please?

@johnny9
johnny9 force-pushed the remove-gmock-dependency branch 3 times, most recently from 0df5590 to f9154ab Compare July 21, 2026 14:26
Comment thread test/CMakeLists.txt
get_target_property(qt_lib_type Qt6::Core TYPE)
if(qt_lib_type STREQUAL "STATIC_LIBRARY")
qt6_import_plugins(bitcoinqml_unit_tests INCLUDE Qt6::QMinimalIntegrationPlugin)
qt6_import_plugins(bitcoinqml_qmltests INCLUDE Qt6::QMinimalIntegrationPlugin)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hebasto can you confirm if this is correct? I tried offscreen but it seems it isn't available on macos.

@johnny9 johnny9 Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess not, ci failing

@johnny9
johnny9 force-pushed the remove-gmock-dependency branch from f9154ab to 54ee9e1 Compare July 21, 2026 16:30
$(package)_config_opts_darwin := -no-dbus
$(package)_config_opts_darwin += -no-feature-printsupport
-$(package)_config_opts_darwin += -no-feature-freetype
+$(package)_config_opts_darwin += -qt-freetype

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hebasto This seems to be required for Qt to build the offscreen qpa for macos

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use offscreen for gui automation testing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hebasto This seems to be required for Qt to build the offscreen qpa for macos

we use offscreen for gui automation testing

bitcoin/bitcoin#35551 (review)

bitcoin/bitcoin#35551 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use offscreen for gui automation testing

Is it for sure that the minimal plugin can't be used?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have some qml tests that fail on minimal due to some differences with window focus but I'm looking again and I think they can be rewritten to work with minimal and still provide the correct test coverage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and pushed the changes to use minimal

@johnny9

johnny9 commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

Rebased and ready for review

@johnny9
johnny9 force-pushed the remove-gmock-dependency branch from 54ee9e1 to de58e55 Compare July 23, 2026 12:20
Comment thread CMakeLists.txt Outdated
@johnny9
johnny9 force-pushed the remove-gmock-dependency branch 2 times, most recently from ed1eb19 to abe69e3 Compare July 29, 2026 20:37
johnny9 added 2 commits July 30, 2026 09:32
Replace gMock with small handwritten Node and Wallet test doubles.

The doubles expose a `calls` object with one counter per configurable function, using the same name and case as the function. Every configurable override increments its counter. Tests declare exact, minimum, or zero-call expectations, and `VerifyOnExit()` checks them at the end of the scope. Expectations start from the count at registration time, so calls made during setup do not affect checks for the action under test.

Tests control results through function callbacks and check captured arguments or event lists directly. The wallet double falls back to harmless stub values for behavior a test does not configure. The normal node double also permits unconfigured calls, while `StrictMockNode` records them and reports them together at scope exit. This keeps call behavior visible in each test without recreating a matcher language.
Reuse QtTest's existing window for tests that need a visible scene. The minimal platform does not reliably expose child objects created under a separate Window with static Qt 6.8.3.
@johnny9
johnny9 force-pushed the remove-gmock-dependency branch from abe69e3 to cd06356 Compare July 30, 2026 13:42
Build app tests by default when GUI support is enabled, while retaining the explicit BUILD_APP_TESTS opt-out.

Build and run the app tests in the depends CI job, use the minimal QPA platform, and import the static Qt minimal and QML plugins needed by the test binaries.
@johnny9
johnny9 force-pushed the remove-gmock-dependency branch from cd06356 to cee0b56 Compare July 30, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants