Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QTestLog Class Reference

#include <qtestlog_p.h>

+ Collaboration diagram for QTestLog:

Public Types

enum  LogMode {
  Plain = 0 , XML , LightXML , JUnitXML ,
  CSV , TeamCity , TAP
}
 

Public Member Functions

 QTestLog ()=delete
 
 ~QTestLog ()=delete
 
 Q_ENUM (LogMode)
 

Static Public Member Functions

static void enterTestFunction (const char *function)
 
static void leaveTestFunction ()
 
static void enterTestData (QTestData *data)
 
static void addPass (const char *msg)
 
static void addFail (const char *msg, const char *file, int line)
 
static void addXFail (const char *msg, const char *file, int line)
 
static void addXPass (const char *msg, const char *file, int line)
 
static void addBPass (const char *msg)
 
static void addBFail (const char *msg, const char *file, int line)
 
static void addBXPass (const char *msg, const char *file, int line)
 
static void addBXFail (const char *msg, const char *file, int line)
 
static void addSkip (const char *msg, const char *file, int line)
 
static void addBenchmarkResult (const QList< QBenchmarkResult > &result)
 
static void addBenchmarkResults (const QList< QBenchmarkResult > &result)
 
static void ignoreMessage (QtMsgType type, const char *msg)
 
static void ignoreMessage (QtMsgType type, const QRegularExpression &expression)
 
static void failOnWarning (const char *msg)
 
static void failOnWarning (const QRegularExpression &expression)
 
static int unhandledIgnoreMessages ()
 
static void printUnhandledIgnoreMessages ()
 
static void clearIgnoreMessages ()
 
static void clearFailOnWarnings ()
 
static void clearCurrentTestState ()
 
static void warn (const char *msg, const char *file, int line)
 
static void info (const char *msg, const char *file, int line)
 
static void startLogging ()
 
static void stopLogging ()
 
static void addLogger (LogMode mode, const char *filename)
 
static void addLogger (QAbstractTestLogger *logger)
 
static bool hasLoggers ()
 
static bool loggerUsingStdout ()
 
static void setVerboseLevel (int level)
 
static int verboseLevel ()
 
static void setMaxWarnings (int max)
 
static void setPrintAvailableTagsMode ()
 
static int passCount ()
 
static int failCount ()
 
static int skipCount ()
 
static int blacklistCount ()
 
static int totalCount ()
 
static void resetCounters ()
 
static void setInstalledTestCoverage (bool installed)
 
static bool installedTestCoverage ()
 
static qint64 nsecsTotalTime ()
 
static qreal msecsTotalTime ()
 
static qint64 nsecsFunctionTime ()
 
static qreal msecsFunctionTime ()
 

Related Symbols

(Note that these are not member symbols.)

 failOnWarning
 

Detailed Description

Definition at line 33 of file qtestlog_p.h.

Member Enumeration Documentation

◆ LogMode

Enumerator
Plain 
XML 
LightXML 
JUnitXML 
CSV 
TeamCity 
TAP 

Definition at line 41 of file qtestlog_p.h.

Constructor & Destructor Documentation

◆ QTestLog()

QTestLog::QTestLog ( )
delete

◆ ~QTestLog()

QTestLog::~QTestLog ( )
delete

Member Function Documentation

◆ addBenchmarkResult()

static void QTestLog::addBenchmarkResult ( const QList< QBenchmarkResult > &  result)
inlinestatic

Definition at line 66 of file qtestlog_p.h.

◆ addBenchmarkResults()

void QTestLog::addBenchmarkResults ( const QList< QBenchmarkResult > &  result)
static

Definition at line 474 of file qtestlog.cpp.

References FOREACH_TEST_LOGGER, and results.

Referenced by QuickTestResult::needsMoreMeasurements().

+ Here is the caller graph for this function:

◆ addBFail()

void QTestLog::addBFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 407 of file qtestlog.cpp.

References QAbstractTestLogger::BlacklistedFail, QTest::blacklists, QTest::currentTestState, file, FOREACH_TEST_LOGGER, line, Q_ASSERT, QTEST_ASSERT, QTest::Skipped, QTest::Suppressed, and QTest::Unresolved.

Referenced by QTestResult::addFailure().

+ Here is the caller graph for this function:

◆ addBPass()

void QTestLog::addBPass ( const char *  msg)
static

Definition at line 395 of file qtestlog.cpp.

References QAbstractTestLogger::BlacklistedPass, QTest::blacklists, QTest::currentTestState, FOREACH_TEST_LOGGER, Q_ASSERT, QTEST_ASSERT, QTest::Suppressed, and QTest::Unresolved.

Referenced by QTestResult::finishedCurrentTestDataCleanup().

+ Here is the caller graph for this function:

◆ addBXFail()

void QTestLog::addBXFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 443 of file qtestlog.cpp.

References QAbstractTestLogger::BlacklistedXFail, file, FOREACH_TEST_LOGGER, line, and QTEST_ASSERT.

Referenced by checkStatement().

+ Here is the caller graph for this function:

◆ addBXPass()

void QTestLog::addBXPass ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 425 of file qtestlog.cpp.

References QAbstractTestLogger::BlacklistedXPass, QTest::blacklists, QTest::currentTestState, file, FOREACH_TEST_LOGGER, line, Q_ASSERT, QTEST_ASSERT, QTest::Skipped, QTest::Suppressed, and QTest::Unresolved.

Referenced by checkStatement().

+ Here is the caller graph for this function:

◆ addFail()

void QTestLog::addFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 347 of file qtestlog.cpp.

References QTest::currentTestState, QAbstractTestLogger::Fail, QTest::Failed, QTest::fails, file, FOREACH_TEST_LOGGER, line, Q_ASSERT, QTEST_ASSERT, QTest::Skipped, and QTest::Unresolved.

Referenced by QTestResult::addFailure().

+ Here is the caller graph for this function:

◆ addLogger() [1/2]

void QTestLog::addLogger ( LogMode  mode,
const char *  filename 
)
static

Definition at line 499 of file qtestlog.cpp.

References addLogger(), QXmlTestLogger::Complete, CSV, JUnitXML, QXmlTestLogger::Light, LightXML, Plain, QTEST_ASSERT, TAP, TeamCity, and XML.

Referenced by addLogger(), and QTest::qtest_qParseArgs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addLogger() [2/2]

void QTestLog::addLogger ( QAbstractTestLogger logger)
static

Adds a new logger to the set of loggers that will be used to report incidents and messages during testing.

The function takes ownership of the logger.

Definition at line 551 of file qtestlog.cpp.

References QTEST_ASSERT.

◆ addPass()

void QTestLog::addPass ( const char *  msg)
static

Definition at line 332 of file qtestlog.cpp.

References QTest::currentTestState, FOREACH_TEST_LOGGER, QAbstractTestLogger::Pass, QTest::Passed, QTest::passes, Q_ASSERT, QTEST_ASSERT, and QTest::Unresolved.

Referenced by QTestResult::finishedCurrentTestDataCleanup().

+ Here is the caller graph for this function:

◆ addSkip()

void QTestLog::addSkip ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 453 of file qtestlog.cpp.

References QTest::currentTestState, QTest::Failed, file, FOREACH_TEST_LOGGER, line, Q_ASSERT, QTEST_ASSERT, QAbstractTestLogger::Skip, QTest::Skipped, QTest::skips, QTest::Suppressed, and QTest::Unresolved.

Referenced by QTestResult::addSkip().

+ Here is the caller graph for this function:

◆ addXFail()

void QTestLog::addXFail ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 367 of file qtestlog.cpp.

References file, FOREACH_TEST_LOGGER, line, QTEST_ASSERT, and QAbstractTestLogger::XFail.

Referenced by checkStatement().

+ Here is the caller graph for this function:

◆ addXPass()

void QTestLog::addXPass ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 377 of file qtestlog.cpp.

References QTest::currentTestState, QTest::Failed, QTest::fails, file, FOREACH_TEST_LOGGER, line, Q_ASSERT, QTEST_ASSERT, QTest::Skipped, QTest::Unresolved, and QAbstractTestLogger::XPass.

Referenced by checkStatement().

+ Here is the caller graph for this function:

◆ blacklistCount()

int QTestLog::blacklistCount ( )
static

Definition at line 657 of file qtestlog.cpp.

References QTest::blacklists.

Referenced by QPlainTestLogger::stopLogging(), and totalCount().

+ Here is the caller graph for this function:

◆ clearCurrentTestState()

void QTestLog::clearCurrentTestState ( )
static

Definition at line 327 of file qtestlog.cpp.

References QTest::currentTestState, and QTest::Unresolved.

Referenced by QTestResult::finishedCurrentTestDataCleanup(), and QTestResult::finishedCurrentTestFunction().

+ Here is the caller graph for this function:

◆ clearFailOnWarnings()

void QTestLog::clearFailOnWarnings ( )
static

Definition at line 322 of file qtestlog.cpp.

References QTest::failOnWarningList.

Referenced by QTestResult::finishedCurrentTestData().

+ Here is the caller graph for this function:

◆ clearIgnoreMessages()

void QTestLog::clearIgnoreMessages ( )
static

Definition at line 315 of file qtestlog.cpp.

References QTest::IgnoreResultList::clearList(), QTest::ignoreResultList, and QTest::mutex.

Referenced by QTestResult::finishedCurrentTestData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enterTestData()

void QTestLog::enterTestData ( QTestData data)
static

Definition at line 265 of file qtestlog.cpp.

References FOREACH_TEST_LOGGER, and QTEST_ASSERT.

Referenced by QTestResult::setCurrentTestData().

+ Here is the caller graph for this function:

◆ enterTestFunction()

void QTestLog::enterTestFunction ( const char *  function)
static

Definition at line 253 of file qtestlog.cpp.

References elapsedFunctionTime, FOREACH_TEST_LOGGER, function, QTEST_ASSERT, and QElapsedTimer::restart().

Referenced by QTestResult::setCurrentTestFunction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ failCount()

int QTestLog::failCount ( )
static

Definition at line 647 of file qtestlog.cpp.

References QTest::fails.

Referenced by QuickTestResult::exitCode(), QuickTestResult::failCount(), QTest::qRun(), saveCoverageTool(), stopLogging(), QPlainTestLogger::stopLogging(), QTapTestLogger::stopLogging(), and totalCount().

+ Here is the caller graph for this function:

◆ failOnWarning() [1/2]

void QTestLog::failOnWarning ( const char *  msg)
static

Definition at line 616 of file qtestlog.cpp.

References QTest::failOnWarningList, and QString::fromUtf8().

+ Here is the call graph for this function:

◆ failOnWarning() [2/2]

static void QTestLog::failOnWarning ( const QRegularExpression expression)
static

◆ hasLoggers()

bool QTestLog::hasLoggers ( )
static

Definition at line 557 of file qtestlog.cpp.

Referenced by QTest::messageHandler(), and QTest::qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ ignoreMessage() [1/2]

void QTestLog::ignoreMessage ( QtMsgType  type,
const char *  msg 
)
static

Definition at line 598 of file qtestlog.cpp.

References QTest::IgnoreResultList::append(), QString::fromUtf8(), QTest::ignoreResultList, QTest::mutex, and QTEST_ASSERT.

Referenced by QTest::ignoreMessage(), and QuickTestResult::ignoreWarning().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ignoreMessage() [2/2]

static void QTestLog::ignoreMessage ( QtMsgType  type,
const QRegularExpression expression 
)
static

◆ info()

void QTestLog::info ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 580 of file qtestlog.cpp.

References file, FOREACH_TEST_LOGGER, QString::fromUtf8(), QAbstractTestLogger::Info, line, and QTEST_ASSERT.

Referenced by compareHelper(), compareHelper(), QTest::qFindTestData(), QTest::qPrintMessage(), QTestResult::reportResult(), and QTestResult::verify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installedTestCoverage()

bool QTestLog::installedTestCoverage ( )
static

Definition at line 679 of file qtestlog.cpp.

References QTest::installedTestCoverage.

Referenced by stopLogging().

+ Here is the caller graph for this function:

◆ leaveTestFunction()

void QTestLog::leaveTestFunction ( )
static

Definition at line 285 of file qtestlog.cpp.

References FOREACH_TEST_LOGGER.

Referenced by QTestResult::finishedCurrentTestFunction(), and QTest::messageHandler().

+ Here is the caller graph for this function:

◆ loggerUsingStdout()

bool QTestLog::loggerUsingStdout ( )
static

Definition at line 562 of file qtestlog.cpp.

References FOREACH_TEST_LOGGER.

Referenced by QTest::qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ msecsFunctionTime()

static qreal QTestLog::msecsFunctionTime ( )
inlinestatic

Definition at line 117 of file qtestlog_p.h.

References nsecsFunctionTime().

Referenced by QXmlTestLogger::leaveTestFunction(), and printTestRunTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ msecsTotalTime()

static qreal QTestLog::msecsTotalTime ( )
inlinestatic

Definition at line 115 of file qtestlog_p.h.

References nsecsTotalTime().

Referenced by printTestRunTime(), QJUnitTestLogger::stopLogging(), QPlainTestLogger::stopLogging(), and QXmlTestLogger::stopLogging().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nsecsFunctionTime()

qint64 QTestLog::nsecsFunctionTime ( )
static

Definition at line 689 of file qtestlog.cpp.

References elapsedFunctionTime, and QElapsedTimer::nsecsElapsed().

Referenced by msecsFunctionTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ nsecsTotalTime()

qint64 QTestLog::nsecsTotalTime ( )
static

Definition at line 684 of file qtestlog.cpp.

References elapsedTotalTime, and QElapsedTimer::nsecsElapsed().

Referenced by msecsTotalTime().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ passCount()

int QTestLog::passCount ( )
static

Definition at line 642 of file qtestlog.cpp.

References QTest::passes.

Referenced by QuickTestResult::passCount(), saveCoverageTool(), QPlainTestLogger::stopLogging(), QTapTestLogger::stopLogging(), and totalCount().

+ Here is the caller graph for this function:

◆ printUnhandledIgnoreMessages()

void QTestLog::printUnhandledIgnoreMessages ( )
static

Definition at line 294 of file qtestlog.cpp.

References FOREACH_TEST_LOGGER, QTest::ignoreResultList, QAbstractTestLogger::Info, list, and QTest::mutex.

Referenced by QTestResult::finishedCurrentTestData().

+ Here is the caller graph for this function:

◆ Q_ENUM()

QTestLog::Q_ENUM ( LogMode  )

◆ resetCounters()

void QTestLog::resetCounters ( )
static

Definition at line 667 of file qtestlog.cpp.

References QTest::fails, QTest::passes, and QTest::skips.

Referenced by QTestResult::reset().

+ Here is the caller graph for this function:

◆ setInstalledTestCoverage()

void QTestLog::setInstalledTestCoverage ( bool  installed)
static

Definition at line 674 of file qtestlog.cpp.

References QTest::installedTestCoverage.

Referenced by QTest::qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ setMaxWarnings()

void QTestLog::setMaxWarnings ( int  max)
static

Definition at line 630 of file qtestlog.cpp.

References QTest::maxWarnings.

Referenced by QTest::qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ setPrintAvailableTagsMode()

void QTestLog::setPrintAvailableTagsMode ( )
static

Definition at line 637 of file qtestlog.cpp.

Referenced by QTest::qPrintDataTags().

+ Here is the caller graph for this function:

◆ setVerboseLevel()

void QTestLog::setVerboseLevel ( int  level)
static

Definition at line 588 of file qtestlog.cpp.

References QTest::verbosity.

Referenced by QTest::qtest_qParseArgs().

+ Here is the caller graph for this function:

◆ skipCount()

int QTestLog::skipCount ( )
static

Definition at line 652 of file qtestlog.cpp.

References QTest::skips.

Referenced by QuickTestResult::skipCount(), QJUnitTestLogger::stopLogging(), QPlainTestLogger::stopLogging(), and totalCount().

+ Here is the caller graph for this function:

◆ startLogging()

void QTestLog::startLogging ( )
static

Definition at line 480 of file qtestlog.cpp.

References elapsedFunctionTime, elapsedTotalTime, FOREACH_TEST_LOGGER, QTest::messageHandler(), QTest::oldMessageHandler, qInstallMessageHandler(), and QElapsedTimer::start().

Referenced by QTest::qInit(), and QuickTestResult::startLogging().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stopLogging()

void QTestLog::stopLogging ( )
static

Definition at line 489 of file qtestlog.cpp.

References QTestResult::currentAppName(), failCount(), FOREACH_TEST_LOGGER, installedTestCoverage(), QTest::oldMessageHandler, qInstallMessageHandler(), and saveCoverageTool().

Referenced by QTest::messageHandler(), QTest::qCleanup(), QuickTestResult::setProgramName(), and QuickTestResult::stopLogging().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ totalCount()

int QTestLog::totalCount ( )
static

Definition at line 662 of file qtestlog.cpp.

References blacklistCount(), failCount(), passCount(), and skipCount().

Referenced by QTapTestLogger::addIncident(), and QTapTestLogger::stopLogging().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unhandledIgnoreMessages()

int QTestLog::unhandledIgnoreMessages ( )
static

Definition at line 273 of file qtestlog.cpp.

References i, QTest::ignoreResultList, list, and QTest::mutex.

Referenced by QTestResult::finishedCurrentTestData().

+ Here is the caller graph for this function:

◆ verboseLevel()

int QTestLog::verboseLevel ( )
static

◆ warn()

void QTestLog::warn ( const char *  msg,
const char *  file,
int  line 
)
static

Definition at line 572 of file qtestlog.cpp.

References file, FOREACH_TEST_LOGGER, QString::fromUtf8(), line, QTEST_ASSERT, and QAbstractTestLogger::Warn.

Referenced by QTest::qFindTestData(), and QuickTestResult::warn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ failOnWarning()

failOnWarning ( )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.3

Appends a test failure to the test log if the message is output.

See also
failOnWarning()

Referenced by QTest::failOnWarning().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: