GUI unit testing with Qt Test – part 1 – introduction

This tutorial is an introduction to GUI unit testing with Qt Test. A working example is discussed and analysed in detail. Full qmake project and C++ source code are provided.

GUI unit testing with Qt Test

In this tutorial I will introduce GUI unit testing with Qt Test, the Qt framework for C++ unit testing. In particular I will discuss how to write a basic unit test for a widget class, how to simulate mouse and keyboard events and how to write data driven tests for GUIs.

This is the third post of a series dedicated to Qt Test. The posts of this series are:

  • C++ unit testing with Qt Test


    1. raghu

      I getting an error as below:
      error: cannot find -lWidgetsLib
      error: ld returned 1 exit status

      PS: Am using QT on Windows 10.

      1. Davide Coppola (Post author)

        Are you using the Visual Studio compiler to build?

      2. raghu_reply

        You can find a fix for Winbdows here :

    2. saurabh

      Thank you Davide for such a nice blogs on QT unit testing it has helped me a lot !!

    3. Kumar


      I am new to QT development.

      In that mentioned example, you have divided actual application into ExampleApp and WidgetsLib. WidgetsLib included in both ExampleApp and TestPanelConcat applications.

      But in my case, there is no library and the actual application has whole business logic. In this case how can i proceed to write test case for ui. Can you please explain how to proceed in this case with a nice a example if possible.


    4. Boobisha Boob

      hello sir how u test code with no friend class i canot add class friend to code

      1. Davide Coppola (Post author)

    Leave a Comment

    Your email address will not be published. Required fields are marked *