Qt: How to organize Unit Test with more than one class?

后端 未结 6 1546
温柔的废话
温柔的废话 2020-12-29 03:10

I have a Qt Unit test (sub)project, which generates me one class (with the main generated by QTEST_APPLESS_MAIN).I can start this from within Qt Creator as cons

6条回答
  •  情深已故
    2020-12-29 03:26

    The way I do it:

    • Create a general "subdirs" project.
    • Put the code under test in a C++ library subproject.
    • Instead of using a unit test project, I use a console application subproject.
    • Link the library to this console application, don't forget to handle the dependencies in the .pro file at the top of the hierarchy.
    • In this console subproject, define as many test classes as you wish, and launch them in the main of this same project.

    I basically made a slight variation of this post.

提交回复
热议问题