Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Unit testing with Qt Test - tutorial series
Forum Update on Monday, May 27th 2025

Unit testing with Qt Test - tutorial series

Scheduled Pinned Locked Moved Showcase
17 Posts 11 Posters 7.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivaladav
    wrote on 29 Nov 2017, 12:18 last edited by
    #6

    I have just published the second tutorial: C++ unit testing with Qt Test – part 2 – advanced testing.

    It explains how to handle a project with multiple unit tests and how to implement data driven testing. There are also examples of more testing macros and an overview of the Qt Test integration offered by Qt Creator.

    Questions, comments and feedback are always welcome.

    Davide Coppola
    blog | Linkedin | Twitter

    1 Reply Last reply
    4
    • P Offline
      P Offline
      Paul Thexton
      wrote on 30 Nov 2017, 23:08 last edited by
      #7

      Hi,

      I wish I'd found this tutorial a few days ago when I started looking at some (Basic) unit testing using Qt!

      On the subject of feeding Qt Test results in to other systems, I've been doing that to get the results in to TFS/VSTS (it's what we're using at work, it's non-negotiable) and I've found that the xunitxml support in Qt is actually xunit v1, whereas VSTS/TFS only supports xunit v2 xml.

      I've put together an XSL stylesheet to do the transformation for me, but really it's a pretty clunky way around the problem and I'd much prefer the test runner logs directly to a suitable format.

      Where would be the best place to suggest updating it (or adding an additional format)? Alternatively I'd be happy to submit code to update this via open source, but I'm not sure where to start looking for how to contribute code!

      I'll look forward to reading your following blogs :)

      V J 2 Replies Last reply 2 Dec 2017, 14:38
      3
      • P Paul Thexton
        30 Nov 2017, 23:08

        Hi,

        I wish I'd found this tutorial a few days ago when I started looking at some (Basic) unit testing using Qt!

        On the subject of feeding Qt Test results in to other systems, I've been doing that to get the results in to TFS/VSTS (it's what we're using at work, it's non-negotiable) and I've found that the xunitxml support in Qt is actually xunit v1, whereas VSTS/TFS only supports xunit v2 xml.

        I've put together an XSL stylesheet to do the transformation for me, but really it's a pretty clunky way around the problem and I'd much prefer the test runner logs directly to a suitable format.

        Where would be the best place to suggest updating it (or adding an additional format)? Alternatively I'd be happy to submit code to update this via open source, but I'm not sure where to start looking for how to contribute code!

        I'll look forward to reading your following blogs :)

        V Offline
        V Offline
        vivaladav
        wrote on 2 Dec 2017, 14:38 last edited by
        #8

        @Paul-Thexton hey Paul,

        I am not a Qt developer, but to the best of my knowledge you could create a feature request in the Qt bug tracker or you can submit a patch using Gerrit.

        Let us know how it goes :)

        Davide Coppola
        blog | Linkedin | Twitter

        A 1 Reply Last reply 2 Dec 2017, 17:16
        5
        • V vivaladav
          2 Dec 2017, 14:38

          @Paul-Thexton hey Paul,

          I am not a Qt developer, but to the best of my knowledge you could create a feature request in the Qt bug tracker or you can submit a patch using Gerrit.

          Let us know how it goes :)

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 2 Dec 2017, 17:16 last edited by
          #9

          @vivaladav said in Unit testing with Qt Test - tutorial series:

          @Paul-Thexton hey Paul,

          I am not a Qt developer, but to the best of my knowledge you could create a feature request in the Qt bug tracker or you can submit a patch using Gerrit.

          Let us know how it goes :)

          Your knowledge is correct :)

          @Paul-Thexton I think such a contribution would be very helpful for others also.

          Qt has to stay free or it will die.

          1 Reply Last reply
          3
          • V Offline
            V Offline
            vivaladav
            wrote on 2 Jan 2018, 12:45 last edited by
            #10

            Happy new year!

            I have just published the third tutorial: GUI unit testing with Qt Test – part 1 – introduction

            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.

            Any feedback and questions always welcome.

            Davide Coppola
            blog | Linkedin | Twitter

            1 Reply Last reply
            3
            • P Paul Thexton
              30 Nov 2017, 23:08

              Hi,

              I wish I'd found this tutorial a few days ago when I started looking at some (Basic) unit testing using Qt!

              On the subject of feeding Qt Test results in to other systems, I've been doing that to get the results in to TFS/VSTS (it's what we're using at work, it's non-negotiable) and I've found that the xunitxml support in Qt is actually xunit v1, whereas VSTS/TFS only supports xunit v2 xml.

              I've put together an XSL stylesheet to do the transformation for me, but really it's a pretty clunky way around the problem and I'd much prefer the test runner logs directly to a suitable format.

              Where would be the best place to suggest updating it (or adding an additional format)? Alternatively I'd be happy to submit code to update this via open source, but I'm not sure where to start looking for how to contribute code!

              I'll look forward to reading your following blogs :)

              J Offline
              J Offline
              JulienMaille
              wrote on 6 Jan 2018, 13:17 last edited by
              #11

              @Paul-Thexton said in Unit testing with Qt Test - tutorial series:

              Hi,

              I wish I'd found this tutorial a few days ago when I started looking at some (Basic) unit testing using Qt!

              On the subject of feeding Qt Test results in to other systems, I've been doing that to get the results in to TFS/VSTS (it's what we're using at work, it's non-negotiable) and I've found that the xunitxml support in Qt is actually xunit v1, whereas VSTS/TFS only supports xunit v2 xml.

              I've put together an XSL stylesheet to do the transformation for me, but really it's a pretty clunky way around the problem and I'd much prefer the test runner logs directly to a suitable format.

              Where would be the best place to suggest updating it (or adding an additional format)? Alternatively I'd be happy to submit code to update this via open source, but I'm not sure where to start looking for how to contribute code!

              I'll look forward to reading your following blogs :)

              I see you work with VSTS, which is also what we have at work. Were you able to setup automatic build on VSTS (ie handle all qt depencies required to compile on the online "agent") ?

              P 1 Reply Last reply 3 Feb 2018, 13:19
              1
              • C Offline
                C Offline
                Charlie_Hdz
                wrote on 6 Jan 2018, 18:09 last edited by
                #12

                Wonderful!

                Kind Regards,
                Enrique Hernandez
                gearstech.com.mx
                chernandez@gearstech.com.mx

                1 Reply Last reply
                1
                • V Offline
                  V Offline
                  vivaladav
                  wrote on 12 Jan 2018, 14:12 last edited by
                  #13

                  Finally I published the 4th and final part of this series: GUI unit testing with Qt Test – part 2 – advanced testing

                  This tutorial will introduce more advanced features of Qt Test dedicated to GUI unit testing. In particular it will show how to simulate and handle keyboard focus and how to test Qt signals when unit testing a Graphical User Interface.

                  Any feedback and questions always welcome.

                  Davide Coppola
                  blog | Linkedin | Twitter

                  1 Reply Last reply
                  4
                  • J JulienMaille
                    6 Jan 2018, 13:17

                    @Paul-Thexton said in Unit testing with Qt Test - tutorial series:

                    Hi,

                    I wish I'd found this tutorial a few days ago when I started looking at some (Basic) unit testing using Qt!

                    On the subject of feeding Qt Test results in to other systems, I've been doing that to get the results in to TFS/VSTS (it's what we're using at work, it's non-negotiable) and I've found that the xunitxml support in Qt is actually xunit v1, whereas VSTS/TFS only supports xunit v2 xml.

                    I've put together an XSL stylesheet to do the transformation for me, but really it's a pretty clunky way around the problem and I'd much prefer the test runner logs directly to a suitable format.

                    Where would be the best place to suggest updating it (or adding an additional format)? Alternatively I'd be happy to submit code to update this via open source, but I'm not sure where to start looking for how to contribute code!

                    I'll look forward to reading your following blogs :)

                    I see you work with VSTS, which is also what we have at work. Were you able to setup automatic build on VSTS (ie handle all qt depencies required to compile on the online "agent") ?

                    P Offline
                    P Offline
                    Paul Thexton
                    wrote on 3 Feb 2018, 13:19 last edited by
                    #14

                    @JulienMaille apologies, I didn't get a notification about your message. As far as I know you're probably not going to be able to use the Microsoft 'Hosted' build agents for building Qt projects, I created my own build agent on a Linux VM.

                    1 Reply Last reply
                    0
                    • owenlevineeO Offline
                      owenlevineeO Offline
                      owenlevinee
                      Banned
                      wrote on 26 Feb 2019, 06:41 last edited by
                      #15
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        david_wang
                        wrote on 10 Mar 2022, 02:31 last edited by
                        #16

                        OH MAN ! This is exactly what I want!
                        I am looking for how to run all Unit testing at one time (part2)

                        This is really helpful.

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          Tayyab3
                          Banned
                          wrote on 25 Nov 2022, 12:16 last edited by
                          #17
                          This post is deleted!
                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved