<font size="2"><font face="georgia,serif">Alright, so being completely honest, I first looked at what you sent and thought it was nuts.  However, after getting it to work, it's a much nicer solution (although it may not look it).</font></font><div>

<font size="2"><font face="georgia,serif"><br></font></font></div><div><font size="2"><font face="georgia,serif">So, back to my original question, where should I be putting the cmake macros?  For now, until I hear better, I'll put them in the rosjava/cmake/rosjava.cmake file on my computer.  If they should go somewhere else, let me know, but since Java isn't fully supported, I figured it would be better to keep them out of public and private cmake in rosbuild.</font></font></div>

<div><font size="2"><font face="georgia,serif"><br></font></font></div><div><font size="2"><font face="georgia,serif">If / When I get this to work with ros, I will send out my solution.  For now, if anyone else wants this, to get JUnit to work from the command line I just executed the following script:</font></font></div>

<div><font size="2"><font face="georgia,serif"><br></font></font></div><div><font size="2"><font face="georgia,serif"><div>#!/bin/bash</div><div>#Usage: junit.sh <class path> <test case class file></div><div>
<br>
</div><div>if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then</div><div>  if [ -d /usr/share/ant ] ; then</div><div>     ANT_HOME=/usr/share/ant</div><div>  fi</div><div>fi</div><div><br></div><div># set ANT_LIB location</div>

<div>ANT_LIB="${ANT_HOME}/lib"</div><div><br></div><div># set the classes for the test case runner and xml format</div><div>RUNNER=org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner</div><div>FORMAT=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter</div>

<div><br></div><div># make sure rosjava is on the classpath</div><div>ROS_JAVA=`rospack find rosjava`/bin</div><div><br></div><div># the class path requires the ant jar for exceptions</div><div>export CLASSPATH=$CLASSPATH:$ROS_JAVA:$ANT_LIB/ant.jar:$ANT_LIB/ant-junit.jar:$ANT_LIB/junit4.jar:$1</div>

<div><br></div><div>java $RUNNER $2 formatter=$FORMAT</div><div><br></div></font></font></div><div><font size="2"><font face="georgia,serif"><br></font></font></div><div><font class="Apple-style-span" face="georgia, serif">As an example, one could execute:   ./junit.sh . pkg.to.class.ClassNameTest</font></div>

<div><font size="2"><font face="georgia,serif"><br clear="all"></font></font>Aaron Holroyd<br>B.S. Computer Science and Robotics Engineering<br>WPI M.S. CS 2011<br><a href="http://users.wpi.edu/~aholroyd">http://users.wpi.edu/~aholroyd</a><br>


<br><br><div class="gmail_quote">On Tue, Jul 13, 2010 at 14:19, Ken Conley <span dir="ltr"><<a href="mailto:kwc@willowgarage.com">kwc@willowgarage.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

You shouldn't have to use the ant command-line tool. Instead, you<br>
should just be able to use Ant's classes to generate the XML files<br>
(the XML format is actually an Ant Junit format).<br>
<br>
The class you probably want is:<br>
<br>
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter<br>
<br>
You can probably plug this in as a formatter of:<br>
<br>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner<br>
<br>
though that's just from scanning the source code; I haven't tried this<br>
myself yet.<br>
<br>
Both JUnit and Ant are open-source projects, so it should be fairly<br>
easy to orchestrate the desired behavior.<br>
<br>
Hope this helps,<br>
<font color="#888888">Ken<br>
</font><div><div></div><div class="h5"><br>
On Tue, Jul 13, 2010 at 9:09 AM, Aaron Holroyd <<a href="mailto:aholroyd@wpi.edu">aholroyd@wpi.edu</a>> wrote:<br>
> Hi again,<br>
> I have some updates about the JUnit testing from below.<br>
> After some searching, and talking to someone who works closely with JUnit,<br>
> I've found that I can not export an XML report directly from a JUnit call.<br>
>  Instead I have to call ant and export it from there.<br>
> This gives me 2 questions:<br>
> 1) In order to write this I would have to invoke ant with a premade ant file<br>
> which takes as arguments the classes to test.  This itself is not hard, but<br>
> does this sound like a good solution? I would just have to add an ant build<br>
> file to a known directory.<br>
> 2) If I write this and create a patch, is it ok to add ant to the<br>
> dependencies list for ros, or just for rosjava, or where would this go?<br>
>  Which leads to  should this be written in the rosjava CMake file, or in the<br>
> main public / private cmake files in rosbuild?<br>
> I also, probably, will need help eventually with the CMake files, but I'll<br>
> try them on my own first.  I simply have never written CMake, before I<br>
> started using ROS.<br>
> Thanks again,<br>
> Aaron Holroyd<br>
> B.S. Computer Science and Robotics Engineering<br>
> WPI M.S. CS 2011<br>
> <a href="http://users.wpi.edu/~aholroyd" target="_blank">http://users.wpi.edu/~aholroyd</a><br>
><br>
><br>
> On Tue, Jul 6, 2010 at 16:20, Aaron Holroyd <<a href="mailto:aholroyd@wpi.edu">aholroyd@wpi.edu</a>> wrote:<br>
>><br>
>> I'll take a look at how to add Java JUnit testing to the rosbuild cmake<br>
>> files first.  Whether I get it to work or not, I'll let you know how it<br>
>> goes.<br>
>><br>
>> As for rostest, I had seen this, but I noticed that it is for C++ and<br>
>> Python only.  Once I get CMake JUnit testing  to work the rostest should be<br>
>> fairly straight forward.<br>
>> Aaron Holroyd<br>
>> B.S. Computer Science and Robotics Engineering<br>
>> WPI M.S. CS 2011<br>
>> <a href="http://users.wpi.edu/~aholroyd" target="_blank">http://users.wpi.edu/~aholroyd</a><br>
>><br>
>><br>
>> On Tue, Jul 6, 2010 at 14:04, Brian Gerkey <<a href="mailto:gerkey@willowgarage.com">gerkey@willowgarage.com</a>><br>
>> wrote:<br>
>>><br>
>>> On Tue, Jul 6, 2010 at 7:12 AM, Aaron Holroyd <<a href="mailto:aholroyd@wpi.edu">aholroyd@wpi.edu</a>> wrote:<br>
>>> > I would like to start writing some test cases for rosjava code I have<br>
>>> > written.  Unfortunately, I can't seem to figure out how this should be<br>
>>> > done<br>
>>> > with ROS.<br>
>>> > I've been using Eclipse for my development, and I could continue to<br>
>>> > just use<br>
>>> > it's built in testing environment.  The only problem with this is that<br>
>>> > when<br>
>>> > the code is released, the test cases won't work.  Are there any other<br>
>>> > suggestions, or a preferred way to do this?<br>
>>><br>
>>> hi Aaron,<br>
>>><br>
>>> I don't know enough about Eclipse to give a recommendation there, but<br>
>>> there are two ways that you can test your code at the command-line:<br>
>>><br>
>>> (1) Use rostest (<a href="http://www.ros.org/wiki/rostest" target="_blank">http://www.ros.org/wiki/rostest</a>).  It allows you to<br>
>>> bring up a ROS network, then use a program to run tests against that<br>
>>> network.<br>
>>><br>
>>> (2) Write standalone unit tests.  The ROS build system has support for<br>
>>> running C/C++ (gtest) and Python (pyunit) tests.  We don't yet have<br>
>>> support for Java, which I guess would use JUnit.  It should be easy to<br>
>>> add support.  Look in rosbuild/public.cmake and rosbuild/private.cmake<br>
>>> for how it's done for the other languages.  Essentially, you need to<br>
>>> know the command-line that's required to invoke your compiled test<br>
>>> program, including redirection of test results to a particular<br>
>>> location.  I can help with the CMake integration if you want.<br>
>>><br>
>>> Note that, for (1), if you want to write the test program itself in<br>
>>> Java, then you'll also need the new JUnit support described in (2)<br>
>>> (you could write test programs in Python or C++ using the current<br>
>>> infrastructure).<br>
>>><br>
>>>        brian.<br>
>><br>
><br>
><br>
</div></div><div><div></div><div class="h5">> _______________________________________________<br>
> ros-users mailing list<br>
> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
><br>
><br>
_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</div></div></blockquote></div><br></div>