Chapter 6: Skipping Tests with QSKIP¶
How to skip tests in certain cases.
Using QSKIP(
description
) in a test function¶
If the
QSKIP()
macro is called from a test function, it stops the execution of the test without adding a failure to the test log. It can be used to skip tests that are certain to fail. The text in the QSKIPdescription
parameter is appended to the test log, and explains why the test was not carried out.QSKIP can be used to skip testing when the implementation is not yet complete or not supported on a certain platform. When there are known failures, it is recommended to use
QEXPECT_FAIL
, so that the test is always completely executed.Example of QSKIP in a test function:
if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0).toInt() < 5) QSKIP("Test requires MySQL >= 5.0");In a data-driven test, each call to
QSKIP()
skips only the current row of test data. If the data-driven test contains an unconditional call to QSKIP, it produces a skip message for each row of test data.
Using QSKIP in a _data function¶
Using QSKIP from initTestCase() or initTestCase_data()¶
If called from
initTestCase()
orinitTestCase_data()
, theQSKIP()
macro will skip all test and _data functions.
© 2022 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.