summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2022-10-14 13:58:26 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2023-01-31 17:35:13 +0100
commit24f3e0f21cd3971939945c18c6b9895609a01875 (patch)
treee568c28148395eeafda267d7aeed59a40e52936d
parent2d73cc2b1df03df716e6a76f9dca7761c1363368 (diff)
Improve documentation of data-driven tests
Mention addRow() as well as newRow(), even though the example only uses the latter. Link the best-practice section to the fuller story. Fixed a minor grammar glitch in the manual while I was about it. Pick-to: 6.5 Change-Id: Ib1c52cd8d2b6a04ea944d24d9d26c901b6cdf4e7 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/testlib/doc/src/qttest-best-practices.qdoc4
-rw-r--r--src/testlib/doc/src/qttestlib-manual.qdoc21
2 files changed, 14 insertions, 11 deletions
diff --git a/src/testlib/doc/src/qttest-best-practices.qdoc b/src/testlib/doc/src/qttest-best-practices.qdoc
index 91ff87dcf5..4220312149 100644
--- a/src/testlib/doc/src/qttest-best-practices.qdoc
+++ b/src/testlib/doc/src/qttest-best-practices.qdoc
@@ -154,8 +154,8 @@
\section2 Use Data-driven Testing
- Data-driven tests make it easier to add new tests for boundary conditions
- found in later bug reports.
+ \l{Chapter 2: Data Driven Testing}{Data-driven tests} make it easier to add
+ new tests for boundary conditions found in later bug reports.
Using a data-driven test rather than testing several items in sequence in
a test saves repetition of very similar code and ensures later cases are
diff --git a/src/testlib/doc/src/qttestlib-manual.qdoc b/src/testlib/doc/src/qttestlib-manual.qdoc
index f810f2f4a3..2d89693d35 100644
--- a/src/testlib/doc/src/qttestlib-manual.qdoc
+++ b/src/testlib/doc/src/qttestlib-manual.qdoc
@@ -403,7 +403,7 @@
Setting this variable to a non-zero value will cause a failure in
an autotest to immediately abort the entire autotest. This is useful
to e.g. debug an unstable or intermittent failure in a test, by
- launching the test in a debugger. Support for this variable has been
+ launching the test in a debugger. Support for this variable was
added in Qt 6.1.
\endlist
@@ -689,14 +689,17 @@
expected result of applying the QString::toUpper() function to
that string.
- Then, we add some data to the table using the \l
- 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 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
+ Then, we add some data to the table using the \l QTest::newRow()
+ function. We can also use \l QTest::addRow() if we need to format some data
+ in the row name, for example when generating many data rows iteratively.
+ Each row 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 and used in the test log to identify the data row. \l
+ QTest::addRow() takes a (\c{printf}-style) format string followed by the
+ parameters to be represented in place of the formatting tokens in the format
+ string. 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.
You can think of the test data as a two-dimensional table. In