> Sent: Wednesday, June 23, 2021 at 11:45 AM > From: "Kai Köhne" <kai.koe...@qt.io> > To: "Jason H" <jh...@gmx.com>, "interestqt-project.org" > <interest@qt-project.org> > Subject: RE: [Interest] make check not working (macOS) > > HI Jason, > > It looks to me like you're trying to add a test case into your normal > application executable. Is that correct?
Yes. > The canonical use of QTest is different: You create a separate project for > the tests, in a separate directory. If you e.g. check back on > https://doc.qt.io/qt-5/qttestlib-tutorial1-example.html , this creates a new > file testqstring.cpp, and then uns "qmake -project" in the directory to > create a completely new project. > > Hope this helps. Yes it does. Thanks! So I have to manually maintain the modules being tested as a separate project? If so, that's pretty undesirable because of the manual effort to make sure that the test project is using the same source that the actual application uses. I hope I can automate that somehow? (Preferably requiring 0 maintenance) I would not be opposed to a "tests" subdir to hold this project, but then, that needs it's own .pro, and it needs to automatically reference the parent project's files. Immediately I am thinking I can just use HEADERS/SOURCES files with ../ prefixes but that violates my 0-maintenance requirement. I want a brain-dead, simple, 0-maintenance test kit. The only thing the developers should have to worry about is adding test implementations once it is started. Can this be achieved in Qt? =========== Unit tests like this should focus on testing small targeted items. The classes under test should only include the limited number of items. If you had a "mainwindow" directory, with 5 classes, I would recommend you have 5 or more test files, one for each class. Creating 5 different executables with 5 different testharnesses. Once its setup, its pretty straight forward to maintain, but Ive never seen a brain-dead, simple, 0-maintenance test "kit". The easiest I have used is CMake + GoogleTest + QTest. I use CMake for the test harness and either google test and qtest depending on what is being tested. They both work in a very similar fashion. You create a new executable for each group of tests you are testing. For a more automated setup, I will often have the unittest directory as a subdir of the classes directory. And as Thiago suggests have an include of the make system file into the unit test one. Scott _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest