Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Automated testing recomendations
QtWS25 Last Chance

Automated testing recomendations

Scheduled Pinned Locked Moved Unsolved General and Desktop
testinggtestqttest
6 Posts 3 Posters 821 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.
  • J Offline
    J Offline
    jkwok678
    wrote on 28 Jul 2021, 17:07 last edited by
    #1

    Hi,

    I would like to add automated testing onto my build process. But I am not sure whether I should use Google test, Qt test or boost?
    What are the benefits and drawbacks of them?
    Also with the tests, do I need to create a new test project? How would I be able to add automated testing to an existing codebase that uses CMake?

    V 1 Reply Last reply 28 Jul 2021, 17:18
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Jul 2021, 17:11 last edited by
      #2

      Hi,

      The Qt Test is designed to test Qt application/libraries and is included. The other two add two new dependencies and you will have to handle the event loop part yourself.

      You can take a look at the Qt 6 sources to see how you can manage tests.

      Note that it is better to implement unit tests per unit of your library/application. One big contains all tests class will not allow you to have fine grained information about what is working and what not.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 28 Jul 2021, 17:27
      1
      • J jkwok678
        28 Jul 2021, 17:07

        Hi,

        I would like to add automated testing onto my build process. But I am not sure whether I should use Google test, Qt test or boost?
        What are the benefits and drawbacks of them?
        Also with the tests, do I need to create a new test project? How would I be able to add automated testing to an existing codebase that uses CMake?

        V Offline
        V Offline
        VRonin
        wrote on 28 Jul 2021, 17:18 last edited by
        #3

        @jkwok678 said in Automated testing recomendations:

        How would I be able to add automated testing to an existing codebase that uses CMake?

        CTest can handle this easily

        You can take a look at the Qt 6 sources to see how you can manage tests.

        While it's is a solid advice, that repo is very advanced.
        Have a look first at this example repo for the initial starting point, you can refine it later on

        "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

        1 Reply Last reply
        2
        • S SGaist
          28 Jul 2021, 17:11

          Hi,

          The Qt Test is designed to test Qt application/libraries and is included. The other two add two new dependencies and you will have to handle the event loop part yourself.

          You can take a look at the Qt 6 sources to see how you can manage tests.

          Note that it is better to implement unit tests per unit of your library/application. One big contains all tests class will not allow you to have fine grained information about what is working and what not.

          J Offline
          J Offline
          jkwok678
          wrote on 28 Jul 2021, 17:27 last edited by jkwok678
          #4

          @SGaist Do you mean that I should create maybe a new test project for every class?
          @VRonin Is CTest an alternative to Qt Test and the other testing frameworks?

          Also in terms of ease of use and functionality, which one do you think would be best?
          I have only used JUnit with Java before, are there any testing frameworks that are fairly similar?

          V 1 Reply Last reply 28 Jul 2021, 18:08
          0
          • J jkwok678
            28 Jul 2021, 17:27

            @SGaist Do you mean that I should create maybe a new test project for every class?
            @VRonin Is CTest an alternative to Qt Test and the other testing frameworks?

            Also in terms of ease of use and functionality, which one do you think would be best?
            I have only used JUnit with Java before, are there any testing frameworks that are fairly similar?

            V Offline
            V Offline
            VRonin
            wrote on 28 Jul 2021, 18:08 last edited by VRonin
            #5

            @jkwok678 said in Automated testing recomendations:

            Do you mean that I should create maybe a new test project for every class?

            Yes, QtTest works better that way. Usually a project would just consist of a .cpp file and a CMakeLists.txt

            Is CTest an alternative to Qt Test and the other testing frameworks?

            No, CTest is the framework to integrate tests (GoogleTest, QtTest, etc.) into CMake projects.

            Also in terms of ease of use and functionality, which one do you think would be best?

            For Qt projects I only used QtTest so I'm not in a position to offer an opinion

            "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

            1 Reply Last reply
            2
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Jul 2021, 18:12 last edited by
              #6

              CTest is the test runner.

              Yes that's the starting point.

              Then you can have separated functional tests where you validate the high level functionalities and finally integration tests where you ensure that the final application is working as expected.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2

              5/6

              28 Jul 2021, 18:08

              • Login

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