Pretty unit test dlls with QTest lib
-
Hi Folks,
to be familiar with the situation: I have a relatively large project:
- root (it is a subdir project)
** QApplication project
** C++ dll project
** C++ dll project
** and C++ dll projects n times
and I would like to do unit test project almost each of those projects. I think, the proper solution would be, that I create unit test projects each of dll projects, like this:
- root (it is a subdir project)
** QApplication project
** C++ dll project <-> related unit test project
** C++ dll project <-> related unit test project
** and C++ dll projects n times <-> related unit test projects
The organisation is realy important for me, so I prefer the following project structure:
- root (it is a subdir project)
** QApplication project
** C++ dll project
** C++ dll project
** and C++ dll projects n times
** unit test root (it is a subdir project)
*** the main executable program, which deploy all of unit tests
*** unit test project, which is a dll linked together with the related project dll
*** unit test project, which is a dll linked together with the related project dll
*** unit test projects n times, which are a dll linked together with the related project dlls
My problem is the following: as I see, the Qt unit test framwork is prepared for create unit tests for each classes and pass a main method to each of them, like:
@
class coretestTest: public QObject {
Q_OBJECTpublic: coretestTest() = default;
private slots: void testCase1();
};void coretestTest::testCase1() {
QVERIFY2(true, "Failure");
}
QTEST_APPLESS_MAIN(coretestTest)#include "tst_coretesttest.moc"
@does exist any !!!OFFICIAL!!! way to create unit test projects, which produces only a dll, and I'm able to link them to one .exe? I guess, that it is easy to solve by coding maunaly, but I'm wondering a standardised, official solution.
Regards,
Norbert - root (it is a subdir project)
-
Hi,
AFAIK, there's no standardized, official way for that. The philosophy as I understand (and use it) is to have each unit test completely self contained.
I am curious though, why do you want to create one exec with every unit test linked to it ?
-
Hi,
because it seems more maintable as creating standalone exes for each classes in my project.
I think, it is better that 1 by 1 relation exists between the "production" and unit test classes, but the unit test is compiled into single program ( the collection of .exe and .dlls). In this case I can run it more simpler.Regards,
Norbert -
I don't find it more maintainable, it means that each time you add a unit test you have to modify your monolithic test application. Also, if your on a team, you might end up with several people writing unit tests, modifying the same exec code which isn't necessarily maintenance friendly.
There are also several levels of testing. Unit tests that only take cares of your specific classes to ensure that when you modify it, it still working. Then you have "functional" tests where you put some of your classes together to ensure they are working as you want. And then you application test using something like e.g. Squish.
You should keep a clean separation for every level.