summaryrefslogtreecommitdiffstats
path: root/src/testlib/doc/src/qttestlib-manual.qdoc
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-24 01:00:14 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-10-24 10:23:44 +0200
commitb327807c5ed6f151bfb22c2fe204ed289a3b6254 (patch)
tree880a0e7664e1270f4f51ccf79a3cf2ddbcd7d810 /src/testlib/doc/src/qttestlib-manual.qdoc
parentaa4b0f5cb7e84046530fbc26581f777506fea658 (diff)
parentb61c6164c100defc519b178d73858df59cffc48d (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts: src/corelib/io/qstandardpaths_unix.cpp src/corelib/tools/qsharedpointer_impl.h tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: Iae95c5778dc091058f16f6db76f04a0178a9e809
Diffstat (limited to 'src/testlib/doc/src/qttestlib-manual.qdoc')
-rw-r--r--src/testlib/doc/src/qttestlib-manual.qdoc53
1 files changed, 42 insertions, 11 deletions
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index 65836d0706..bb379fe029 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -89,12 +89,14 @@
private slot is a test function in your test. QTest::qExec() can be used to execute
all test functions in the test object.
- In addition, there are four private slots that are \e not treated as test functions.
- They will be executed by the testing framework and can be used to initialize and
- clean up either the entire test or the current test function.
+ In addition, you can define the following private slots that are \e not
+ treated as test functions. When present, they will be executed by the
+ testing framework and can be used to initialize and clean up either the
+ entire test or the current test function.
\list
\li \c{initTestCase()} will be called before the first test function is executed.
+ \li \c{initTestCase_data()} will be called to create a global test data table.
\li \c{cleanupTestCase()} will be called after the last test function was executed.
\li \c{init()} will be called before each test function is executed.
\li \c{cleanup()} will be called after every test function.
@@ -358,18 +360,44 @@
counters can be obtained by running any benchmark executable with the
option \c -perfcounterlist.
- \list
- \li \b Notes:
+ \note
\list
\li Using the performance counter may require enabling access to non-privileged
applications.
\li Devices that do not support high-resolution timers default to
one-millisecond granularity.
\endlist
- \endlist
See \l {Chapter 5: Writing a Benchmark}{Writing a Benchmark} in the Qt Test
Tutorial for more benchmarking examples.
+
+ \section1 Using Global Test Data
+
+ You can define \c{initTestCase_data()} to set up a global test data table.
+ Each test is run once for each row in the global test data table. When the
+ test function itself \l{Chapter 2: Data-driven Testing}{is data-driven},
+ it is run for each local data row, for each global data row. So, if there
+ are \c g rows in the global data table and \c d rows in the test's own
+ data-table, the number of runs of this test is \c g times \c d.
+
+ Global data is fetched from the table using the \l QFETCH_GLOBAL() macro.
+
+ The following are typical use cases for global test data:
+
+ \list
+ \li Selecting among the available database backends in QSql tests to run
+ every test against every database.
+ \li Doing all networking tests with and without SSL (HTTP versus HTTPS)
+ and proxying.
+ \li Testing a timer with a high precision clock and with a coarse one.
+ \li Selecting whether a parser shall read from a QByteArray or from a
+ QIODevice.
+ \endlist
+
+ For example, to test each number provided by \c {roundTripInt_data()} with
+ each locale provided by \c {initTestCase_data()}:
+
+ \snippet code/src_qtestlib_qtestcase.cpp 31
*/
/*!
@@ -513,10 +541,9 @@
QTest::newRow() function. Each set of data will become a
separate row in the test table.
- \l QTest::newRow() takes one argument: a name that will be
- associated with the data set. If the test fails, the name will be
- used in the test log, referencing the failed data. Then we
- stream the data set into the new table row. First an arbitrary
+ \l QTest::newRow() takes one argument: a name that will be associated
+ with the data set and used in the test log to identify the data set.
+ Then we stream the data set into the new table row. First an arbitrary
string, and then the expected result of applying the
QString::toUpper() function to that string.
@@ -548,6 +575,10 @@
\li HELLO
\endtable
+ When data is streamed into the row, each datum is asserted to match
+ the type of the column whose value it supplies. If any assertion fails,
+ the test is aborted.
+
\section1 Rewriting the Test Function
Our test function can now be rewritten: