Using many slots to test many classes in Qt unit testing -


i've seen variety of workarounds posted in various places suggest writing custom main functions instead of relying on qt qtest_main() macro when creating single test execution works through many different tests of different classes.

correct me if i'm wrong, couldn't have single test class , have many slots need test many classes want? instantiate desired class want test inside slot's implementation , run tests in slot. then, different slot might instantiate different class , run different tests. single qtest_main supposed run through slot tests, gets tested, right?

here of alternate techniques i've read don't use qtest_main:

https://sites.google.com/a/embeddedlab.org/community/technical-articles/qt/qt-posts/creatingandexecutingasingletestprojectwithmultipleunittests

https://stackoverflow.com/a/12207504/768472

of course can have slots want in test class. sooner or later need separate tests , group them because have many tests place them in 1 class. , have create several test classes.

the original intent of qtest_main function run 1 test. if want test several classes , can independently of each other, can put them in separate test classes, add qtest_main macro each of them , compile each class separate executable. plus if 1 test case crushes, other tests continue run properly. minus need test runner run tests , check results, , qtestlib doesn't provide runner. can write own runner or use 1 of existing ones (example).

the options are:

  • to obey paradigm of qtestlib. separate tests different executables prevent test failing because of other tests.
  • to store test in 1 class. if app not tiny, inconvenient.
  • to run tests manually using custom main function. it's not bad, it's inconvenient because need list test classes manually.
  • to use test lib. prefer google test. it's more powerful qtestlib, supports death tests, automatically registers , runs tests , counts results. there no such problems in google test. note can use many useful qtestlib features (like qsignalspy) along test framework.

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -