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:
parent
755d1b2948
commit
2de82be7f1
@ -154,8 +154,8 @@
|
|||||||
|
|
||||||
\section2 Use Data-driven Testing
|
\section2 Use Data-driven Testing
|
||||||
|
|
||||||
Data-driven tests make it easier to add new tests for boundary conditions
|
\l{Chapter 2: Data Driven Testing}{Data-driven tests} make it easier to add
|
||||||
found in later bug reports.
|
new tests for boundary conditions found in later bug reports.
|
||||||
|
|
||||||
Using a data-driven test rather than testing several items in sequence in
|
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
|
a test saves repetition of very similar code and ensures later cases are
|
||||||
|
@ -403,7 +403,7 @@
|
|||||||
Setting this variable to a non-zero value will cause a failure in
|
Setting this variable to a non-zero value will cause a failure in
|
||||||
an autotest to immediately abort the entire autotest. This is useful
|
an autotest to immediately abort the entire autotest. This is useful
|
||||||
to e.g. debug an unstable or intermittent failure in a test, by
|
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.
|
added in Qt 6.1.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
@ -689,14 +689,17 @@
|
|||||||
expected result of applying the QString::toUpper() function to
|
expected result of applying the QString::toUpper() function to
|
||||||
that string.
|
that string.
|
||||||
|
|
||||||
Then, we add some data to the table using the \l
|
Then, we add some data to the table using the \l QTest::newRow()
|
||||||
QTest::newRow() function. Each set of data will become a
|
function. We can also use \l QTest::addRow() if we need to format some data
|
||||||
separate row in the test table.
|
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
|
\l QTest::newRow() takes one argument: a name that will be associated with
|
||||||
with the data set and used in the test log to identify the data set.
|
the data set and used in the test log to identify the data row. \l
|
||||||
Then, we stream the data set into the new table row. First an arbitrary
|
QTest::addRow() takes a (\c{printf}-style) format string followed by the
|
||||||
string, and then the expected result of applying 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.
|
QString::toUpper() function to that string.
|
||||||
|
|
||||||
You can think of the test data as a two-dimensional table. In
|
You can think of the test data as a two-dimensional table. In
|
||||||
|
Loading…
x
Reference in New Issue
Block a user