Skip to content

Commit f509760

Browse files
committed
Merge #576: Add qt unit test runner summary
d025d7f gui, refactor: rename fInvalid to num_test_failures in test_main.cpp (Jon Atack) 2489b6f gui: count test failures in test runner summary (Jon Atack) ba44aae gui: add test runner summary (Jon Atack) Pull request description: Append a one-line summary to the output of running `./src/qt/test/test_bitcoin-qt` indicating that all tests passed or showing the number of failing tests. It's currently a bit inconvenient to see this result by eyeballing all of the output. ACKs for top commit: shaavan: ACK d025d7f jarolrod: tACK d025d7f Tree-SHA512: 981c5daa13db127d38167bcf78b296b1a7e5b2d12e65f364ec6382b24f1008a223521d3b6c56e920bcd037479da5414e43758794688019d09e9aa696f3964746
2 parents 0f46e73 + d025d7f commit f509760

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/qt/test/test_main.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
#endif // ENABLE_WALLET
2222

2323
#include <QApplication>
24+
#include <QDebug>
2425
#include <QObject>
2526
#include <QTest>
27+
2628
#include <functional>
2729

2830
#if defined(QT_STATICPLUGIN)
@@ -69,8 +71,6 @@ int main(int argc, char* argv[])
6971
gArgs.ForceSetArg("-upnp", "0");
7072
gArgs.ForceSetArg("-natpmp", "0");
7173

72-
bool fInvalid = false;
73-
7474
// Prefer the "minimal" platform for the test instead of the normal default
7575
// platform ("xcb", "windows", or "cocoa") so tests can't unintentionally
7676
// interfere with any background GUIs and don't require extra resources.
@@ -86,32 +86,32 @@ int main(int argc, char* argv[])
8686
app.setApplicationName("Bitcoin-Qt-test");
8787
app.createNode(*init);
8888

89+
int num_test_failures{0};
90+
8991
AppTests app_tests(app);
90-
if (QTest::qExec(&app_tests) != 0) {
91-
fInvalid = true;
92-
}
92+
num_test_failures += QTest::qExec(&app_tests);
93+
9394
OptionTests options_tests(app.node());
94-
if (QTest::qExec(&options_tests) != 0) {
95-
fInvalid = true;
96-
}
95+
num_test_failures += QTest::qExec(&options_tests);
96+
9797
URITests test1;
98-
if (QTest::qExec(&test1) != 0) {
99-
fInvalid = true;
100-
}
98+
num_test_failures += QTest::qExec(&test1);
99+
101100
RPCNestedTests test3(app.node());
102-
if (QTest::qExec(&test3) != 0) {
103-
fInvalid = true;
104-
}
101+
num_test_failures += QTest::qExec(&test3);
102+
105103
#ifdef ENABLE_WALLET
106104
WalletTests test5(app.node());
107-
if (QTest::qExec(&test5) != 0) {
108-
fInvalid = true;
109-
}
105+
num_test_failures += QTest::qExec(&test5);
106+
110107
AddressBookTests test6(app.node());
111-
if (QTest::qExec(&test6) != 0) {
112-
fInvalid = true;
113-
}
108+
num_test_failures += QTest::qExec(&test6);
114109
#endif
115110

116-
return fInvalid;
111+
if (num_test_failures) {
112+
qWarning("\nFailed tests: %d\n", num_test_failures);
113+
} else {
114+
qDebug("\nAll tests passed.\n");
115+
}
116+
return num_test_failures;
117117
}

0 commit comments

Comments
 (0)