PDA

View Full Version : Proper Test Suite example



Mookie
13th December 2015, 22:47
This question crosses the boundary between qmake and code.

I'm having some trouble getting my head around the correct use of "CONFIG += testcase".

All the examples show to make a single "Test Case" object in a source file and then add the



QTEST_MAIN(TestCaseClassname)
#include "testcasefilename.moc"


This doesn't allow for multiple test cases in one executable though, since it creates main functions.


Isn't it possible to write a "Test Suite", defined as a collection of test cases, that runs all the cases in single executable?
If so, doesn't "CONFIG += testcase" do this somehow so it can trigger with "make check"?
Is there a decent example somewhere?

anda_skoa
14th December 2015, 07:05
The concept followed by QTestLib (and many other Unittesting frameworks) is to isolate the tests for each unit into one executable.
Makes it less likely that tests interfere with each other, rebuilds tests only for changed units, can build and run tests even if other units currently don't compile, etc.

You can add a custom target to the .pro file of the unittest directory which then calls each test.
See https://github.com/KDAB/KDSoap/blob/master/unittests/unittests.pro for example.

Cheers,
_

anda_skoa
17th December 2015, 18:27
It is even easier than that!

Just found this http://doc.qt.io/qt-5/qmake-common-projects.html#building-a-testcase

Cheers,
_