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.

Change-Id: Ib1c52cd8d2b6a04ea944d24d9d26c901b6cdf4e7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 24f3e0f21cd3971939945c18c6b9895609a01875)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Edward Welbourne 2022-10-14 13:58:26 +02:00 committed by Qt Cherry-pick Bot
parent 755d1b2948
commit 2de82be7f1
2 changed files with 13 additions and 10 deletions

View File

@ -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

View File

@ -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.
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 set.
Then, we stream the data set into the new table row. First an arbitrary
string, and then the expected result of applying the
\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