Download the latest version (v.0.0.3) of the single header file here.
To enable easy, convenient testing and Approval Testing of Qt-based C++ code by using modern test frameworks.
Currently Catch is supported.
QImage
. You give it a QImage, it saves this as a .png, and then verifies it by reading it back in.QTableView
. You give it a QTableView, and it saves its text contents in a tab-separated .tsv file.You can download the Starter Project and start experimenting.
QCOMPARE
, QVERIFY
, QTRY_COMPARE
and so on. Currently, any test failures of all any of the Qt Test macros will be silently swallowed, and tests will spuriously pass.QCOMPARE
, but not the others.// main.cpp:
#define APPROVALS_CATCH_QT
#include "ApprovalTestsQt.hpp"
This takes a QImage, and saves this as a .png, and then verifies it by reading it back in.
In general, it's better to verify behaviour of objects rather than their appearance. However, if you do wish to test the contents of a QImage, this will work well.
QImage image(10, 20, QImage::Format_RGB32);
image.fill(Qt::red);
ApprovalTestsQt::verifyQImage(image);
This takes QTableView, and saves its text contents in a tab-separated .tsv, for verification.
QTableWidget tableWidget;
populateTable(tableWidget);
ApprovalTestsQt::verifyQTableView(tableWidget);
Check out the Features page or upcoming release notes to see what we've been working on lately, or browse the past release notes.