diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2021-10-08 13:58:27 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2021-11-26 04:47:24 +0100 |
commit | efb283fb7f72e950c8ecf755b960a3c1b36b5507 (patch) | |
tree | 361930e1f30586e93f3b4165a9893cdd381d2517 /tests/auto/testlib/selftests/expected_warnings.junitxml | |
parent | 1edf153a6bc28e127531e852a0856025ca5d91b0 (diff) |
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 <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests/expected_warnings.junitxml')
-rw-r--r-- | tests/auto/testlib/selftests/expected_warnings.junitxml | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/tests/auto/testlib/selftests/expected_warnings.junitxml b/tests/auto/testlib/selftests/expected_warnings.junitxml index 691bb32a80..92285a4937 100644 --- a/tests/auto/testlib/selftests/expected_warnings.junitxml +++ b/tests/auto/testlib/selftests/expected_warnings.junitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite name="tst_Warnings" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="7" failures="4" errors="0" skipped="0" time="@TEST_DURATION@"> +<testsuite name="tst_Warnings" timestamp="@TEST_START_TIME@" hostname="@HOSTNAME@" tests="15" failures="10" errors="0" skipped="1" time="@TEST_DURATION@"> <properties> <property name="QTestVersion" value="@INSERT_QT_VERSION_HERE@"/> <property name="QtVersion" value="@INSERT_QT_VERSION_HERE@"/> @@ -49,5 +49,63 @@ <![CDATA[Did not receive message: "Warning1"]]> </system-out> </testcase> + <testcase name="testFailOnWarnings" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="Received a warning that resulted in a failure:"> + <![CDATA[Ran out of cabbage!]]> + </failure> + <system-out> + <![CDATA[Ran out of tortillas!]]> + <![CDATA[Ran out of oil!]]> + <![CDATA[Running low on toothpaste!]]> + <![CDATA[Running low on toothpaste!]]> + </system-out> + <system-err> + <![CDATA[Ran out of space!]]> + <![CDATA[nope]]> + <![CDATA[Running low on flour!]]> + </system-err> + </testcase> + <testcase name="testFailOnWarningsCleared" classname="tst_Warnings" time="@TEST_DURATION@"> + <system-err> + <![CDATA[Ran out of muffins!]]> + </system-err> + </testcase> + <testcase name="testFailOnWarningsWithData(warning1)" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="Received a warning that resulted in a failure:"> + <![CDATA[warning1]]> + </failure> + <system-err> + <![CDATA[warning2]]> + <![CDATA[warning3]]> + </system-err> + </testcase> + <testcase name="testFailOnWarningsWithData(warning2)" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="Received a warning that resulted in a failure:"> + <![CDATA[warning2]]> + </failure> + <system-err> + <![CDATA[warning1]]> + <![CDATA[warning3]]> + </system-err> + </testcase> + <testcase name="testFailOnWarningsWithData(warning3)" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="Received a warning that resulted in a failure:"> + <![CDATA[warning3]]> + </failure> + <system-err> + <![CDATA[warning1]]> + <![CDATA[warning2]]> + </system-err> + </testcase> + <testcase name="testFailOnWarningsFailInHelper" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="This failure message should be printed but not cause the test to abort"/> + </testcase> + <testcase name="testFailOnWarningsThenSkip" classname="tst_Warnings" time="@TEST_DURATION@"> + <failure type="fail" message="Received a warning that resulted in a failure:"> + <![CDATA[Ran out of cabbage!]]> + </failure> + <skipped message="My cabbage! :("/> + </testcase> + <testcase name="testFailOnWarningsAndIgnoreWarnings" classname="tst_Warnings" time="@TEST_DURATION@"/> <testcase name="cleanupTestCase" classname="tst_Warnings" time="@TEST_DURATION@"/> </testsuite> |