I have two sets of tests (functional and unit tests) and I want to be able to specify which set to run through cmake.
One set of tests are my unittests that I want to run by doing "make test".
Another set of tests are my functional tests that I would like to run by doing "make functionaltests".
Currently both are part of ctest, in that I run both suites through add_test. My CMakeLists.txt file is like this:
FOREACH(functional_test ${functional_tests})
ADD_TEST(NAME functional_test COMMAND f_test.sh functional_test)
ENDFOREACH(functional_test)
FOREACH(unit_test ${unit_tests})
ADD_TEST(NAME unit_test COMMAND u_test.sh unit_test)
ENDFOREACH(unit_test)
I want to leverage ctest for both suites because it gives me a nice, readable format for the test suite (which tests passed and which failed).
I would prefer to not have to create a custom executable, create a target called functionaltests for it, and try to mimic how ctest prints out test results.
When you run ctest you can give it a regular expression to choose what tests to run. So you can name the tests in your CMakeLists file according to a pattern which supports this:
Now you can run the functional tests:
Or the unit tests:
If you want to create targets so that you can execute these through make, you can do:
Then you can run:
You may want to add dependencies to the custom commands so that they cause whatever executable you're testing to rebuild if necessary.