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. TDD in Qt, how to use?
Forum Updated to NodeBB v4.3 + New Features

TDD in Qt, how to use?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 11.7k Views 1 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.
  • E Offline
    E Offline
    Exotic_Devel
    wrote on 4 Jun 2014, 21:54 last edited by
    #1

    What is the correct way to use TDD in Qt? Create tests in the project itself or a separate project for each test?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      adolby
      wrote on 6 Jun 2014, 00:36 last edited by
      #2

      You can take a look at the Qt Testing Framework. You could also use other C++ testing libraries, and they can work out just fine, too.

      Here's some discussion on unit testing in Qt: "http://stackoverflow.com/q/1524390/1583123":http://stackoverflow.com/q/1524390/1583123

      If you decide to use the Qt Testing Framework, take a look at the overview here: "http://qt-project.org/doc/qt-5/qtest-overview.html":http://qt-project.org/doc/qt-5/qtest-overview.html

      And there's a good example on writing a unit test here: "http://qt-project.org/doc/qt-5/qttestlib-tutorial1-example.html":http://qt-project.org/doc/qt-5/qttestlib-tutorial1-example.html

      A common paradigm is to create a separate project for tests. Here's some discussion on including the classes in your main project in your test project: "http://stackoverflow.com/q/11804038/1583123":http://stackoverflow.com/q/11804038/1583123. One answer there suggests using a .pri file and including in in your main project and test project. Alternatively, you can use * in your test project file to include all header and source files from your main project.

      You can create a single test project for all your tests, or multiple projects to group your tests.

      Here is how you can create multiple tests in the same project:

      Read "this article":http://stackoverflow.com/q/1524390/1583123 (linked earlier) about alternatives to Qt Testing Framework. There are multiple posts there that include useful information on creating multiple test classes in the same project.

      Also, there are some useful test supplement classes for the Qt Testing Framework written by individuals. Here's a good supplement from the Qt Creator Blog: "http://qtcreator.blogspot.ca/2010/04/sample-multiple-unit-test-project.html":http://qtcreator.blogspot.ca/2010/04/sample-multiple-unit-test-project.html

      1 Reply Last reply
      0

      1/2

      4 Jun 2014, 21:54

      • Login

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