No subject


Thu May 27 11:52:52 EDT 2010


no help is given to write the code of the tests themselves=2C is this right=
? I have previously been using cppunit=2C and it looks like this will still=
 be useful.




To sum it up=2C I'm looking for real life advice on what you guys have done=
 with ctest. This information seem almost completely missing on the net=2C =
where all searches on ctest leads to useless presentation on ctest features=
.




Cheers=2C



Bo Thorsen.

Monty Program AB.



--=20



MariaDB: MySQL replacement

Community developed. Feature enhanced. Backward compatible.

_______________________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at http://www.kitware.com/opensour=
ce/opensource.html



Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.=
org/Wiki/CMake_FAQ



Follow this link to subscribe/unsubscribe:

http://www.cmake.org/mailman/listinfo/cmake




_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensour=
ce/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.=
org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake 		 	   		  =

--_ed9067e3-f506-4c53-b35b-3e75b5788672_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Tahoma
}
--></style>
</head>
<body class=3D'hmmessage'>
While I was suspecting something like this about CTest=2C your explanation =
helps a lot.<br><br>I have integrated UnitTest++ into my flow=2C and it is =
working quite well.&nbsp=3B It does also return a 0 if all tests pass=2C so=
 one could integrate with CTest/CDash if desirable.<br><br>Thanks<br><hr id=
=3D"stopSpelling">Date: Fri=2C 9 Jul 2010 14:54:46 -0700<br>From: chillery-=
cmake at lambda.nu<br>To: bo at askmonty.org<br>CC: cmake at cmake.org<br>Subject: R=
e: [CMake] CTest examples<br><br>For CTest=2C running a test means running =
an executable and seeing whether the result of that process is 0 (success) =
or not 0 (failure). It is also possible to scan the output of the executabl=
e for certain regular expressions to determine success or failure.<br>
<br>It's a very simple and somewhat limited mechanism. It does depend on yo=
u writing your own test driver=2C which makes sense because CMake can't pos=
sibly know how to test your code.<br><br>As an example=2C Zorba is an XQuer=
y (xml query language) processor. The majority of our tests are actual XQue=
ries stored in text files with the extension .xq=2C along with correspondin=
g expected results in .xml files. We have a testdriver program which execut=
es the query=2C checks the results=2C and returns 0 or 1.<br>
<br>Our CMakeLists looks vaguely like this:<br><br>add_executable(testdrive=
r ${TESTDRIVER_SRCS})<br>file(GLOB_RECURSE TESTFILES "${CMAKE_CURRENT_SOURC=
E_DIR}" "*.xq")<br>foreach(TESTFILE ${TESTFILES})<br>
&nbsp=3B add_test(${TESTFILE} testdriver ${TESTFILE})<br>endforeach()<br><b=
r>This creates one test for each .xq file. The name of the test is the name=
 of the .xq file=2C and that same name is passed as an argument to testdriv=
er.<br>
<br>This works well=2C and lets us use ctest's functionality like -R to run=
 certain tests by name. It also results in nice easy-to-read listings on CD=
ash because there's one line for each test=2C making it easy to examine fai=
lures. (Although given that we have over 20=2C000 tests=2C some pages on CD=
ash take a looooong time to load...) The main downside is speed=2C since ev=
ery single test has to start up a whole Zorba process.<br>
<br>When you get to unit testing=2C however=2C IMHO things don't work as we=
ll. CMake does offer the create_test_sourcelist() command=2C and you should=
 look into it. We use that in a couple places to create a single test drive=
r from several separate small unit test drivers. However=2C you still need =
to write a loop in CMakeLists to add multiple tests using that test driver.=
<br>
<br>In another project I work on=2C I've been using CxxTest for a unit test=
ing framework. This is a really nice setup as it makes it very trivial to w=
rite many unit tests. However=2C the integration with ctest is poor. There'=
s a reasonably good FindCxxTest script shipped with CMake that makes it eas=
y to get CxxTest suites running=3B in a nutshell:<br>
<br>find_package(CxxTest)<br>cxx_add_test(my_unit_test my_unit_test.cpp "${=
CMAKE_CURRENT_SOURCE_DIR}/my_unit_test.h")<br><br>Unit tests in CxxTest are=
 written as classes in a .h file=3B cxx_add_test() runs CxxTest to generate=
 the named .cpp file from that=2C then builds it into the named test driver=
 and adds a CTest test for it. So far so good. However=2C the main benefit =
of CxxTest is grouping similar test cases into a single .h file=2C probably=
 with similar setup and so forth. Unfortunately cxx_add_test() only adds on=
e test to CTest=2C and that one test runs all the test cases in the .h file=
. So you lose the ability to run certain tests with ctest -R=2C and the rep=
orts on CDash will just show whether ALL the tests in my_unit_test succeede=
d or not.<br>
<br>The fundamental problem is that ctest requires a test case to be a prog=
ram execution=2C and has no facilities to allow a program to represent mult=
iple tests. So either you pay the cost in speed=2C or you lose some of the =
flexibility ctest and cdash offer. (To be fair=2C even if this were fixed i=
n ctest=2C CxxTest would also need some modifications as it currently doesn=
't let you run subsets of tests either.)<br>
<br>Ceej<br>aka Chris Hillery<br><br><div class=3D"ecxgmail_quote">On Fri=
=2C Jul 9=2C 2010 at 4:37 AM=2C Bo Thorsen <span dir=3D"ltr">&lt=3B<a href=
=3D"mailto:bo at askmonty.org">bo at askmonty.org</a>&gt=3B</span> wrote:<br><blo=
ckquote class=3D"ecxgmail_quote" style=3D"padding-left: 1ex=3B">
Hi people=2C<br>
<br>
I have converted a set of applications to cmake and cpack=2C and now have m=
y eyes set on ctest.<br>
<br>
I'd like to hear if someone here has some good advice=2C or links to good a=
dvice=2C on how to structure tests. I'm searching for help on how to put di=
fferent tests into what executables. On how to handle multiple tests on eac=
h classes=2C on how to best structure the test of the static libraries (all=
 of those are part of the source tree) that are linked in to the applicatio=
n. And on how to test classes from the main application itself.<br>

<br>
I have read the ctest FAQ=2C documentation etc. and still don't know anythi=
ng that help me write the actual test code.<br>
<br>


More information about the CMake mailing list