Obsolete Members for QTest

The following members of class QTest are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

Functions

(deprecated in 6.4) bool compare_helper(bool success, const char *failureMsg, char *actualVal, char *expectedVal, const char *actual, const char *expected, const char *file, int line)
(deprecated in 6.3) void qWarn(const char *message, const char *file = nullptr, int line = 0)

Macros

(deprecated in 6.3) QVERIFY_EXCEPTION_THROWN(expression, exceptiontype)
(deprecated) QWARN(message)

Function Documentation

[deprecated in 6.4] bool QTest::compare_helper(bool success, const char *failureMsg, char *actualVal, char *expectedVal, const char *actual, const char *expected, const char *file, int line)

This function is deprecated since 6.4. We strongly advise against using it in new code.

This function is called by various specializations of QTest::qCompare to decide whether to report a failure and to produce verbose test output.

The failureMsg parameter can be null, in which case a default message will be output if the compare fails. If the compare succeeds, failureMsg will not be output.

Using this function is not optimal, because it requires the string representations of actualVal and expectedVal to be pre-calculated, even though they will be used only if the comparison fails. Prefer using the compare_helper() overload that takes qxp::function_ref() for such cases.

If the caller creates a custom failure message showing the compared values, or if those values cannot be stringified, use the overload of the function that takes no actualVal and expectedVal parameters.

[deprecated in 6.3] void QTest::qWarn(const char *message, const char *file = nullptr, int line = 0)

This function is deprecated since 6.3. We strongly advise against using it in new code.

Use qWarning() instead

Macro Documentation

[deprecated in 6.3] QVERIFY_EXCEPTION_THROWN(expression, exceptiontype)

This macro is deprecated since 6.3. We strongly advise against using it in new code.

Use QVERIFY_THROWS_EXCEPTION(exceptiontype, expression) instead.

[deprecated] QWARN(message)

This macro is deprecated. We strongly advise against using it in new code.

Use qWarning() instead.

Appends message as a warning to the test log. This macro can be used anywhere in your tests.

Note: This macro is thread-safe.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.