Obsolete Members for QTest | Qt Test | Qt 6.11.2
Description: The QTest namespace contains all the functions and declarations that are related to Qt Test.

- Qt 6.11
- Qt Test
- Obsolete Members for QTest
- Qt 6.11.2 Reference Documentation

# 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.