4#include <QtTest/private/qjunittestlogger_p.h>
5#include <QtTest/private/qtestelement_p.h>
6#include <QtTest/private/qtestjunitstreamer_p.h>
7#include <QtTest/qtestcase.h>
8#include <QtTest/private/qtestresult_p.h>
9#include <QtTest/private/qbenchmark_p.h>
10#include <QtTest/private/qtestlog_p.h>
12#include <QtCore/qlibraryinfo.h>
64 localTime.toString(
Qt::ISODate).toUtf8().constData());
111 for (
auto *testCase : listOfTestcases)
112 currentTestSuite->
addChild(testCase);
113 listOfTestcases.clear();
115 logFormatter->
output(currentTestSuite);
117 delete currentTestSuite;
118 currentTestSuite =
nullptr;
128void QJUnitTestLogger::enterTestCase(
const char *
name)
133 listOfTestcases.push_back(currentTestCase);
135 Q_ASSERT(!systemOutputElement && !systemErrorElement);
152 static const char *lastTestFunction =
nullptr;
163 enterTestCase(testIdentifier.
data());
172void QJUnitTestLogger::leaveTestCase()
178 currentTestCase->
addChild(systemOutputElement);
180 delete systemOutputElement;
183 currentTestCase->
addChild(systemErrorElement);
185 delete systemErrorElement;
187 systemOutputElement =
nullptr;
188 systemErrorElement =
nullptr;
195 auto failureType = [&]() {
199 default: Q_UNREACHABLE();
211 currentTestCase->
addChild(skippedElement);
216 const char *failureType,
const QString &failureDescription)
221 for (
auto *childElement : currentTestCase->childElements()) {
243 currentTestCase->
addChild(failureElement);
245 switch (elementType) {
248 default: Q_UNREACHABLE();
262 auto systemLogElement = [&]() {
267 return systemOutputElement;
271 return systemErrorElement;
277 if (!systemLogElement)
282 systemLogElement->addChild(textNode);
Base class for test loggers.
IncidentTypes
\value Pass The test ran to completion successfully.
virtual void startLogging()
Called before the start of a test run.
MessageTypes
The members whose names begin with Q describe messages that originate in calls, by the test or code u...
virtual void stopLogging()
Called after the end of a test run.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
static QByteArray number(int, int base=10)
Returns a byte-array representing the whole number n as text.
static QDateTime currentDateTime()
This is an overloaded member function, provided for convenience. It differs from the above function o...
qint64 restart() noexcept
Restarts the timer and returns the number of milliseconds elapsed since the previous start.
void start() noexcept
Starts this timer.
qint64 nsecsElapsed() const noexcept
void stopLogging() override
Called after the end of a test run.
void enterTestFunction(const char *function) override
This virtual method is called before each test function is invoked.
void startLogging() override
Called before the start of a test run.
void addMessage(MessageTypes type, const QString &message, const char *file=nullptr, int line=0) override
This is an overloaded member function, provided for convenience. It differs from the above function o...
void enterTestData(QTestData *) override
This virtual method is called before and after each call to a test function.
void addIncident(IncidentTypes type, const char *description, const char *file=nullptr, int line=0) override
This virtual method is called when an event occurs that relates to the resolution of the test.
QJUnitTestLogger(const char *filename)
void leaveTestFunction() override
This virtual method is called after a test function has completed, to match \l enterTestFunction().
static const char * build() noexcept
Returns a string describing how this version of Qt was built.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
This function returns a section of the string.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toUtf8() const &
static QString machineHostName()
void addAttribute(const QTest::AttributeIndex index, const char *value)
const QTestElementAttribute * attribute(QTest::AttributeIndex index) const
bool setPair(QTest::AttributeIndex attributeIndex, const char *value)
const std::vector< QTestElement * > & childElements() const
bool addChild(QTestElement *element)
void output(QTestElement *element) const
static qreal msecsTotalTime()
static const char * currentTestObjectName()
static const char * currentTestFunction()
Combined button and popup list for selecting options.
void generateTestIdentifier(QTestCharBuffer *identifier, int parts)
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt,...)
static const QCssKnownValue properties[NumProperties - 1]
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
static QByteArray toSecondsFormat(qreal ms)
static Q_CONSTINIT QElapsedTimer elapsedTestcaseTime
static qreal elapsedTestCaseSeconds()
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei const GLchar * message
#define QTEST_VERSION_STR
QT_BEGIN_NAMESPACE Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char * qVersion(void) Q_DECL_NOEXCEPT