<HTML>
<HEAD>
<TITLE>Re: [CMake] Need advice for unit test structure</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi Robert,<BR>
<BR>
&nbsp;&nbsp;I don&#8217;t have any suggestions about the compile time unit tests, but we&#8217;ve been using the Google testing framework for the last 6 months and have been very happy with it. &nbsp;I wrote up some details related to ITK here:<BR>
<BR>
<a href="http://www.itk.org/Wiki/Proposals:Increasing_ITK_Code_Coverage#Google_Test">http://www.itk.org/Wiki/Proposals:Increasing_ITK_Code_Coverage#Google_Test</a><BR>
<BR>
You can have multiple tests embedded in one executable, which is what the gtest framework does.<BR>
<BR>
Best regards,<BR>
-dan <BR>
<BR>
<BR>
On 4/2/09 3:00 PM, &quot;Robert Dailey&quot; &lt;<a href="rcdailey@gmail.com">rcdailey@gmail.com</a>&gt; wrote:<BR>
<BR>
</SPAN></FONT><BLOCKQUOTE><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>Hi,<BR>
<BR>
Currently we have a directory called &quot;test&quot; under each project we have. Each source file (CPP) results in 1 unit test project being created. So if we have a project named &quot;foobar&quot;, it would be structured like this on the filesystem:<BR>
<BR>
foobar/test/test1.cpp<BR>
foobar/test/test2.cpp<BR>
foobar/test/test3.cpp<BR>
<BR>
And the generated visual studio projects (when created via CMake) would be:<BR>
<BR>
foobar<BR>
foobar_test1<BR>
foobar_test2<BR>
foobar_test3<BR>
<BR>
Obviously this creates a lot of clutter in the solution explorer window in Visual Studio. Is there a more recommended practice for structuring unit tests in CMake? Personal advice is also welcome. One approach I'd like to take is where we only have two projects:<BR>
<BR>
foobar<BR>
foobar_test<BR>
<BR>
And inside foobar_test, all of the sources under the /test/ directory would be included, so a single project compiles all unit tests.<BR>
<BR>
foobar_test<BR>
  test1.cpp<BR>
  test2.cpp<BR>
  test3.cpp<BR>
<BR>
However, the reason why I'm currently not doing this is because of compile-time unit testing. Basically, some unit tests are designed to be successful if they fail to compile. For example, perhaps certain template parameters do not meet the requirements of a specific C++ concept, and thus rightfully fail. This unit test would be considered successful because we want to make sure that ONLY types matching this specific concept are accepted by the compiler.<BR>
<BR>
If we include these source files in the same project, then it interrupts the whole compilation process. They have to be separate in order to work properly.<BR>
<BR>
<HR ALIGN=CENTER SIZE="3" WIDTH="95%"></SPAN></FONT><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'>_______________________________________________<BR>
Powered by www.kitware.com<BR>
<BR>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><BR>
<BR>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ">http://www.cmake.org/Wiki/CMake_FAQ</a><BR>
<BR>
Follow this link to subscribe/unsubscribe:<BR>
<a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><BR>
</SPAN></FONT></FONT></BLOCKQUOTE><FONT SIZE="2"><FONT FACE="Consolas, Courier New, Courier"><SPAN STYLE='font-size:10pt'><BR>
</SPAN></FONT></FONT><FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>-- <BR>
<B>Daniel Blezek, PhD<BR>
</B>Medical Imaging Informatics Innovation Center<BR>
<BR>
P 127 or (77) 8 8886<BR>
T 507 538 8886<BR>
E <a href="blezek.daniel@mayo.edu">blezek.daniel@mayo.edu</a><BR>
<BR>
Mayo Clinic<BR>
200 First St. S.W.<BR>
Harwick SL-44<BR>
Rochester, MN 55905<BR>
mayoclinic.org<BR>
<BR>
</SPAN></FONT>
</BODY>
</HTML>