[CMake] CTest Question

William A. Hoffman billlist at nycap.rr.com
Thu Jun 29 16:03:13 EDT 2006


At 01:03 PM 6/29/2006, Scott Amort wrote:
>Hi All,
>
>I have one last hurdle in converting my project over to CMake - unit
>testing.  I don't quite understand the CTest framework, and it doesn't
>seem to be doing what I expect.  In my tests subdirectory, I have this
>CMakeLists.txt:
>
>#for testing
>ENABLE_TESTING()
>
>#build testing executables
>ADD_EXECUTABLE(ExceptionTest ExceptionTest.cpp)
>
>#add tests
>ADD_TEST(exception_test ExceptionTest)
>
>Currently, I generate various unit tests (using CxxTest) that result in
>a series of .hpp and .cpp files in my tests subdirectory (e.g.
>ExceptionTest).  With the older autotools setup, I could execute `make
>check', which would then run these tests.  I expected that with CMake, I
>could do a `make test' and get the same result, but it does not seem to
>be working this way (although it does build and link the executable).
>It would also be preferable that the testing sources aren't compiled
>with the project sources, but only when a `make test' or equivalent
>command is run.
>
>Is CTest the right framework to be using?  Am I misunderstanding how to
>use it?  There is not much documentation on the subject.
>
>Thanks for any assistance!

Have you looked at the Wiki:

http://www.cmake.org/Wiki/CMake_Testing_With_CTest#Introduction

make test should do the trick.
You can also run ctest directly in the build tree.
What you have should work.  You might have to move the
ENABLE_TESTING to the top of the project.  Also you can
look for the DartTesting.  You can look for this file
in your build tree and make sure it looks good: 
DartTestfile.txt

-Bill


-Bill



More information about the CMake mailing list