[ros-users] rosjava test

Ken Conley kwc at willowgarage.com
Tue Jul 13 18:19:15 UTC 2010


You shouldn't have to use the ant command-line tool. Instead, you
should just be able to use Ant's classes to generate the XML files
(the XML format is actually an Ant Junit format).

The class you probably want is:

org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter

You can probably plug this in as a formatter of:

org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner

though that's just from scanning the source code; I haven't tried this
myself yet.

Both JUnit and Ant are open-source projects, so it should be fairly
easy to orchestrate the desired behavior.

Hope this helps,
Ken

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



More information about the ros-users mailing list