Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Propagating failing unit tests to Qt Creator issues-pane with QTestLib

Propagating failing unit tests to Qt Creator issues-pane with QTestLib

Scheduled Pinned Locked Moved Qt Creator and other tools
qtcreatorqtestlib
4 Posts 2 Posters 1.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.
  • B Offline
    B Offline
    Borkr
    wrote on 17 Oct 2015, 13:47 last edited by Borkr
    #1

    I recently switched from CppUnit to QTestLib for my projects, and I find making tests is faster and easier. However, I have two concerns. The first being as stated in the title. Using CppUnit I managed to get failing unit tests listed in issues-pane of Qt Creator, which also allowed me to click on it to get to the failing line. How do I set this up with Qt Creator? It is a little hideous to read the Application output/Compile output to find the failing unit tests (even though said output contains the exact same link I wish to have in Issues pane). Test runner is shown below.

    The other concern is more of a nicety, which I guess is what made test development with CppUnit so laborious: auto registering test classes (and registering them.. So many macros).
    Is there a way to do this? As of now I have to manually include their header in my my test runner, as shown below.
    This solution is not scalable....

    #include "unitmain.h"
    
    #include "firstunittest.h"
    #include "secondunittest.h"
    #include "thirdunittest.h"
    
    int UnitMain::unitMain(int argc, char *args[])
    {
        int status = 0;
        auto runTest = [&](QObject * testObject)
        {
            status |= QTest::qExec(testObject, argc, args);
            delete testObject;
        };
    
        runTest(new FirstUnitTest);
        runTest(new SecondUnitTest);
        runTest(new ThirdUnitTest);
        // repeat for all unit tests in the project...
        return status;
    }
    
    int main(int argc, char *args[])
    {
        return UnitMain().unitMain(argc, args);
    }
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 17 Oct 2015, 21:36 last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, it's a feature missing from Qt Creator. You can check that on the bug report system. If you don't find anything, you can open a new feature request for it.

      The general Qt way of unit testing is to have each test as an independent application. I don't see a really easy way to bring them all in only one executable code wise.

      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
      0
      • B Offline
        B Offline
        Borkr
        wrote on 18 Oct 2015, 09:53 last edited by Borkr
        #3

        Hi, and thank you! :-)

        I'll see what I can find in the issue tracker. As for the test, do you mean that every single instance of a unit test is run in a separate executable? If I have 100+ unit tests, I end up with 100+ executables?

        EDIT:
        It seems this was proposed a long time ago
        https://bugreports.qt.io/browse/QTCREATORBUG-86

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 18 Oct 2015, 20:01 last edited by
          #4

          Yes, each unit test gets its own executable. You can check Qt's sources, it's working quite well.

          Thanks for pointing to the request.

          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
          0

          1/4

          17 Oct 2015, 13:47

          • Login

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