January 2018
Intermediate to advanced
486 pages
11h 28m
English
Apart from simple comparisons with input data provided inside each test function, QTest also provides the means to perform unit tests with a more organized and structured set of input data to perform data-driven testing, or, in other words, testing functionalities with different sets of input data. This is done using the QFETCH macro along with the QTest::addColumn and QTest::newRow functions. The QFETCH function can be used inside a test function to fetch the required test data. This needs a data function to be created for our test function. A data function is again another private slot with the exact same name as the test function, but with _data appended to its name. So, if we go back to our previous example, to have ...