1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QJUNITTESTLOGGER_P_H |
5 | #define QJUNITTESTLOGGER_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtTest/qttestglobal.h> |
19 | |
20 | #include <QtTest/private/qabstracttestlogger_p.h> |
21 | #include <QtTest/private/qtestelementattribute_p.h> |
22 | |
23 | #include <vector> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QTestJUnitStreamer; |
28 | class QTestElement; |
29 | |
30 | class QJUnitTestLogger : public QAbstractTestLogger |
31 | { |
32 | public: |
33 | QJUnitTestLogger(const char *filename); |
34 | ~QJUnitTestLogger(); |
35 | |
36 | void startLogging() override; |
37 | void stopLogging() override; |
38 | |
39 | void enterTestFunction(const char *function) override; |
40 | void leaveTestFunction() override; |
41 | |
42 | void enterTestData(QTestData *) override; |
43 | |
44 | void addIncident(IncidentTypes type, const char *description, |
45 | const char *file = nullptr, int line = 0) override; |
46 | void addMessage(MessageTypes type, const QString &message, |
47 | const char *file = nullptr, int line = 0) override; |
48 | |
49 | void addBenchmarkResult(const QBenchmarkResult &) override {} |
50 | |
51 | private: |
52 | void enterTestCase(const char *name); |
53 | void leaveTestCase(); |
54 | |
55 | void addFailure(QTest::LogElementType elementType, |
56 | const char *failureType, const QString &failureDescription); |
57 | |
58 | QTestElement *currentTestSuite = nullptr; |
59 | std::vector<QTestElement*> listOfTestcases; |
60 | QTestElement *currentTestCase = nullptr; |
61 | QTestElement *systemOutputElement = nullptr; |
62 | QTestElement *systemErrorElement = nullptr; |
63 | QTestJUnitStreamer *logFormatter = nullptr; |
64 | |
65 | int testCounter = 0; |
66 | int failureCounter = 0; |
67 | int errorCounter = 0; |
68 | }; |
69 | |
70 | QT_END_NAMESPACE |
71 | |
72 | #endif // QJUNITTESTLOGGER_P_H |
73 | |