2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2020-11-26 16:31:50 +00:00
|
|
|
#include <QTest>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
class tst_JUnit : public QObject
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-07-27 22:03:00 +00:00
|
|
|
tst_JUnit();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void testFunc1();
|
|
|
|
void testFunc2();
|
|
|
|
void testFunc3();
|
|
|
|
void testFunc4();
|
|
|
|
void testFunc5();
|
|
|
|
void testFunc6();
|
|
|
|
void testFunc7();
|
|
|
|
};
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
tst_JUnit::tst_JUnit()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc1()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2021-07-31 16:25:42 +00:00
|
|
|
qWarning("just a qWarning() !");
|
2011-04-27 10:05:43 +00:00
|
|
|
QCOMPARE(1,1);
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc2()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
qDebug("a qDebug() call with comment-ending stuff -->");
|
|
|
|
QCOMPARE(2, 3);
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc3()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2011-10-18 04:53:23 +00:00
|
|
|
QSKIP("skipping this function!");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc4()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QFAIL("a forced failure!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Note there are two testfunctions which give expected failures.
|
|
|
|
This is so we can test that expected failures don't add to failure
|
|
|
|
counts and unexpected passes do. If we had one xfail and one xpass
|
|
|
|
testfunction, we couldn't test which one of them adds to the failure
|
|
|
|
count.
|
|
|
|
*/
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc5()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QEXPECT_FAIL("", "this failure is expected", Abort);
|
|
|
|
QVERIFY(false);
|
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc6()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QEXPECT_FAIL("", "this failure is also expected", Abort);
|
2021-06-11 12:33:41 +00:00
|
|
|
QFAIL("This is a deliberate failure");
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
void tst_JUnit::testFunc7()
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
|
|
|
QEXPECT_FAIL("", "this pass is unexpected", Abort);
|
|
|
|
QVERIFY(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-27 22:03:00 +00:00
|
|
|
QTEST_APPLESS_MAIN(tst_JUnit)
|
|
|
|
#include "tst_junit.moc"
|