Results 1 to 4 of 4

Thread: [UT coverage] How can the industry improve QT code coverage

  1. #1
    Join Date
    Apr 2025
    Posts
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Question [UT coverage] How can the industry improve QT code coverage

    Hello everyone, I am a C++ QT application engineer in the industry.

    After nearly 10 years of iteration, our products are facing the problem of lower and lower code Unit test coverage. Low code coverage is very detrimental to code quality and product quality.

    So we have been looking for ways to improve QT code unit test coverage or some guiding principles.

    I would like to ask industry experts if they can provide some experience to guide us to improve QT unit test coverage?


    Thank you so much.

  2. #2
    Join Date
    Apr 2025
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: [UT coverage] How can the industry improve QT code coverage

    A useful approach is to set coverage metrics as test criteria before merging code, and use mocking to isolate tests. QT testing can be complex, but with the right approach, efficiency comes.

    **Moderator note: Spam URL removed. There is zero tolerance for spamming on this forum. Next time, your posts will be deleted and you will be banned.**
    Last edited by d_stranz; 24th April 2025 at 16:15. Reason: removed URL

  3. #3
    Join Date
    Apr 2025
    Posts
    2
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: [UT coverage] How can the industry improve QT code coverage

    Hi
    Thanks for reply on my question. Now we have a complete QTest framework in out QT application, including many metrics on it. But R&D found it was hard to write the UT since they sometimes felt that it was not smooth enough to cover all of the classes.
    Now in our QT application, we found that refactor the code by the MVC (Model-Viewer-Controller) design to decouple the classes might be also a possible way to help the R&D to write the unit test coding since some classes did not well follow the MVC design.

    If you have more detailed idea on it, pls share more information with us.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,319
    Thanks
    316
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: [UT coverage] How can the industry improve QT code coverage

    Refactoring your code into an MVC design might be a good way to allow implementing unit tests more easily, since the data model is not tightly coupled to the UI in this case. You can test the model using a command line program since the model does not require a user interface.

    Depending on how deeply you want to refactor, you could even package your model into a separate library that could allow testing outside of your application.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 0
    Last Post: 18th February 2015, 04:39
  2. Replies: 0
    Last Post: 19th August 2014, 17:43
  3. Replies: 0
    Last Post: 17th July 2014, 22:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.