Nominate our 2022 Qt Champions!

CuteTest - Unit testing for Qt

  • With CuteTest you can create unit tests and view their results. It's open-source and based on QTestLib but extends it with the following features:

    • You can have multiple test suites (test classes) in a single project.
    • Test suites are registered automatically. No need to manually build the list of test suites.
    • CuteTest provides a public API to retrieve the results of a test run.

    An example of a small test suite:

    @// TestQString.h

    class TESTSUITE(TestQString) TestQString : public QObject {
    private slots:
    void toUpperTest() {
    QString str = "Hello";
    QVERIFY(str.toUpper() == "HELLO");

    void toLowerTest() {
    QString str = "Hello";
    QVERIFY(str.toLower() == "hello");

    This is just a regular QObject-based class. All private slots are test cases (like in QTestLib). The only special thing is the "TESTSUITE" annotation just before the class name. That's it. (You only need to link against CuteTest and QtCore for this to run. See the examples provided by the project.)

    Additionally to the test API CuteTest provides you with a console and a GUI frontend (that are built on CuteTest's API). Especially the GUI frontend make viewing test results much easier than with QTestLib's console output.

    ! GUI frontend)!

    CuteTest has been tested on Windows, Linux (Ubuntu/Gnome), and Mac OS X (Lion). It should, however, run on every operating system that allows the creation of subprocesses.


  • cool this means we can directly test our project with cutetest..
    thank u for sharing this..

  • Thank you... useful tool...

Log in to reply