From efb283fb7f72e950c8ecf755b960a3c1b36b5507 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 8 Oct 2021 13:58:27 +0200 Subject: Add QTest::failOnWarning This solves the long-standing problem of not being able to easily fail a test when a certain warning is output. [ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test function, any warning that matches the given pattern will cause a test failure. The test will continue execution when a failure is added. All patterns are cleared at the end of each test function. Fixes: QTBUG-70029 Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36 Reviewed-by: Edward Welbourne --- src/testlib/qtestresult.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/testlib/qtestresult.cpp') diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 899f5358b5..ae40164392 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -191,6 +191,7 @@ void QTestResult::finishedCurrentTestData() addFailure("Not all expected messages were received"); } QTestLog::clearIgnoreMessages(); + QTestLog::clearFailOnWarnings(); } /*! -- cgit v1.2.3