Working on my new project SynPlayer – an controller to the Synology AudioStation based on C++ and Qt – it becomes evident to set up a testing infrastructure. Keeping dependency small and simple the decision was to facilitate QtTestLib for testing purposes.
To control test parameters and enable result reporting you may set the environment variable TESTARGS, for example to write the tests to the file xunit-result.xml in XUnit XML format pass:
Unfortunately running multiple test cases will cause overwriting the report file with the result for each test, ending up eventually having only the last result.
The test case invocation is done by one of those methods:
QTest::qExec(QObject *test, QStringList args) QTest::qExec(QObject *test, int argc, char **argv)
whereas the command line arguments taken from the TESTARGS variable are passed right into the tests. Supervising the passed parameters let raise the idea of manipulating the output parameters right before the test execution, preferably append the name of the test to the result file name.
For the first try the code sticks to statically replacing all output options with one option enforcing the results to be stored in XUnit XML format in a file named like xunit-result-TestClassName.xml ending up in the following code:
which yields the result files xunit-result-LoginCommandTest.xml and xunit-result-RemotePlayerTest.xml.