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 Updated to NodeBB v4.3 + New Features

Unit testing with Qt Test - tutorial series

Scheduled Pinned Locked Moved Showcase
17 Posts 11 Posters 7.4k Views 4 Watching
  • 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
    VRonin
    wrote on 23 Nov 2017, 09:43 last edited by
    #3

    Thanks, may I suggest a "integrating test results" section to describe how to feed Qt Test results to systems like Travis CI and Jenkins?

    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
    ~Napoleon Bonaparte

    On a crusade to banish setIndexWidget() from the holy land of Qt

    V 1 Reply Last reply 23 Nov 2017, 14:49
    4
    • V vivaladav
      22 Nov 2017, 19:48

      Today I started to publish a series of tutorials about Qt Test, the Qt framework for unit testing.

      The series is made of 4 tutorials:

      • C++ unit testing with Qt Test – part 1 – introduction
      • C++ unit testing with Qt Test – part 2 – advanced testing
      • GUI unit testing with Qt Test – part 1 – introduction
      • GUI unit testing with Qt Test – part 2 – advanced testing

      The other tutorials will be published in the next few weeks. I will update this post after each of them is published.

      Questions and feedback are welcome.

      ? Offline
      ? Offline
      A Former User
      wrote on 23 Nov 2017, 11:06 last edited by
      #4

      @vivaladav Thanks for sharing!

      1 Reply Last reply
      2
      • V VRonin
        23 Nov 2017, 09:43

        Thanks, may I suggest a "integrating test results" section to describe how to feed Qt Test results to systems like Travis CI and Jenkins?

        V Offline
        V Offline
        vivaladav
        wrote on 23 Nov 2017, 14:49 last edited by vivaladav
        #5

        @VRonin that's a great idea for a 4th post. I will definitely do it!

        Thank you for the suggestion.

        Davide Coppola
        blog | Linkedin | Twitter

        1 Reply Last reply
        2
        • 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