Creating a testrunner..
I think i finally found the easiest way to run and organize cppunit tests. Subcommander is split up into several libs and two binaries and a testrunner binary:
subcommander (binary) submerge (binary) sublib (static lib) util (static lib) svn (static lib) testrunner (binary)
So far the testrunner contained the tests and linked with all the libs. The issue with this layout is that if i wanted to write a test for code in the subcommander binary and not in a library i had to add the source files to the testrunner. This gets combersome, especially with QObject based classes which also needs their moc files.
My new layout works upside down. I moved the test classes into its own libraries, …
subcommander (binary) subcommander-test (static lib) ... sublib (static lib) sublib-test (static lib) ...
.. moved the testrunner code into the subcommander binary and link the binary with the test libraries. Running subcommander with the -test command line option will run the tests. Without it, it will run the normal production code.
The test code is a lot easier to handle this way. The only drawback is that the production code now also contains all the test code… but maybe that’s not really a drawback? Everyone can run the tests now.
So far this works really good. :-)