Skip to content

Commit

Permalink
Document what QtTest's various loggers do
Browse files Browse the repository at this point in the history
Provide basic (internal) documentation of each logging class and link
the command-line documentation to pages relevant to the formats not
defined by Qt.

Change-Id: I3251dd1304203c6ab87dfe1f2dec0e9787ab69f8
Reviewed-by: Tor Arne Vestbø <[email protected]>
  • Loading branch information
ediosyncratic committed Mar 22, 2022
1 parent 401349a commit 0e5c39e
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 10 deletions.
20 changes: 20 additions & 0 deletions doc/global/externalsites/external-resources.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -570,3 +570,23 @@
\externalpage https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
\title CreateProcess
*/

/*!
\externalpage https://testanything.org
\title Test Anything Protocol
*/

/*!
\externalpage https://www.jetbrains.com/teamcity/
\title TeamCity
*/

/*!
\externalpage https://junit.org/
\title JUnit XML
*/

/*!
\externalpage https://www.froglogic.com/testcenter/
\title Squish Test Center
*/
6 changes: 3 additions & 3 deletions src/testlib/doc/src/qttestlib-manual.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,14 @@
\li \c -lightxml \br
Outputs results as a stream of XML tags.
\li \c -junitxml \br
Outputs results as an JUnit XML document.
Outputs results as an \l{JUnit XML} document.
\li \c -csv \br
Outputs results as comma-separated values (CSV). This mode is only suitable for
benchmarks, since it suppresses normal pass/fail messages.
\li \c -teamcity \br
Outputs results in TeamCity format.
Outputs results in \l{TeamCity} format.
\li \c -tap \br
Outputs results in Test Anything Protocol (TAP) format.
Outputs results in \l{Test Anything Protocol} (TAP) format.
\endlist

The first version of the \c -o option may be repeated in order to log
Expand Down
10 changes: 9 additions & 1 deletion src/testlib/qappletestlogger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
Expand Down Expand Up @@ -47,6 +47,14 @@ QT_BEGIN_NAMESPACE

using namespace QTestPrivate;

/*! \internal
\class QAppleTestLogger
\inmodule QtTest
QAppleTestLogger reports test results through Apple's unified system logging.
Results can be viewed in the Console app.
*/

bool QAppleTestLogger::debugLoggingEnabled()
{
// Debug-level messages are only captured in memory when debug logging is
Expand Down
10 changes: 10 additions & 0 deletions src/testlib/qcsvbenchmarklogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@
#include "qtestresult_p.h"
#include "qbenchmark_p.h"

/*! \internal
\class QCsvBenchmarkLogger
\inmodule QtTest
QCsvBenchmarkLogger implements a comma-separated value format for benchmarks.
This is intended to be suitable for import into spreadsheets.
It does not print test failures, debug messages, warnings or any other details.
*/

QCsvBenchmarkLogger::QCsvBenchmarkLogger(const char *filename)
: QAbstractTestLogger(filename)
{
Expand Down
12 changes: 11 additions & 1 deletion src/testlib/qjunittestlogger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
Expand Down Expand Up @@ -57,6 +57,16 @@
#include <string.h>

QT_BEGIN_NAMESPACE
/*! \internal
\class QJUnitTestLogger
\inmodule QtTest
QJUnitTestLogger implements logging in a JUnit-compatible XML format.
The \l{JUnit XML} format was originally developed for Java testing.
It is supported by \l{Squish Test Center}.
*/
// QTBUG-95424 links to further useful documentation.

QJUnitTestLogger::QJUnitTestLogger(const char *filename)
: QAbstractTestLogger(filename)
Expand Down
11 changes: 10 additions & 1 deletion src/testlib/qplaintestlogger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
Expand Down Expand Up @@ -213,6 +213,15 @@ namespace QTest {
}
}

/*! \internal
\class QPlainTestLogger
\inmodule QtTest
QPlainTestLogger implements basic logging of test results.
The format is Qt-specific and aims to be be easy to read.
*/

void QPlainTestLogger::outputMessage(const char *str)
{
#if defined(Q_OS_WIN)
Expand Down
14 changes: 12 additions & 2 deletions src/testlib/qtaptestlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@
#endif

QT_BEGIN_NAMESPACE
/*! \internal
\class QTapTestLogger
\inmodule QtTest
QTapTestLogger implements the Test Anything Protocol v13.
The \l{Test Anything Protocol} (TAP) is a simple plain-text interface
between testing code and systems for reporting and analyzing test results.
\sa QAbstractTestLogger
*/

QTapTestLogger::QTapTestLogger(const char *filename)
: QAbstractTestLogger(filename)
Expand Down Expand Up @@ -76,7 +87,7 @@ void QTapTestLogger::stopLogging()

QTestCharBuffer testPlanAndStats;
QTest::qt_asprintf(&testPlanAndStats,
"1..%d\n"
"1..%d\n" // The plan (last non-diagnostic line)
"# tests %d\n"
"# pass %d\n"
"# fail %d\n",
Expand Down Expand Up @@ -265,4 +276,3 @@ void QTapTestLogger::addMessage(MessageTypes type, const QString &message,
}

QT_END_NAMESPACE

9 changes: 8 additions & 1 deletion src/testlib/qteamcitylogger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2017 Borgar Ovsthus
** Contact: https://www.qt.io/licensing/
**
Expand Down Expand Up @@ -99,6 +99,13 @@ namespace QTest {
}
}

/*! \internal
\class QTeamCityLogger
\inmodule QtTest
QTeamCityLogger implements logging in the \l{TeamCity} format.
*/

QTeamCityLogger::QTeamCityLogger(const char *filename)
: QAbstractTestLogger(filename)
{
Expand Down
3 changes: 3 additions & 0 deletions src/testlib/qxctestlogger.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

#import <XCTest/XCTest.h>

// This XCode logging integration has probably bit-rotted since it was written.
// It is not even compiled as part of normal builds.

// ---------------------------------------------------------

@interface XCTestProbe (Private)
Expand Down
22 changes: 21 additions & 1 deletion src/testlib/qxmltestlogger.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtTest module of the Qt Toolkit.
Expand Down Expand Up @@ -101,6 +101,26 @@ namespace QTest {

}

/*! \internal
\class QXmlTestLogger
\inmodule QtTest
QXmlTestLogger implements two XML formats specific to Qt.
The two formats are distinguished by the XmlMode enum.
*/
/*! \internal
\enum QXmlTestLogger::XmlMode
This enumerated type selects the type of XML output to produce.
\value Complete A full self-contained XML document
\value Light XML content suitable for embedding in an XML document
The Complete form wraps the Light form in a <TestCase> element whose name
attribute identifies the test class whose private slots are to be run. It
also includes the usual <?xml ...> preamble.
*/

QXmlTestLogger::QXmlTestLogger(XmlMode mode, const char *filename)
: QAbstractTestLogger(filename), xmlmode(mode)
Expand Down

0 comments on commit 0e5c39e

Please sign in to comment.