ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

Mocking in ROS?

asked 2012-06-19 02:56:44 -0600

Hansg91 gravatar image

Hey,

I'm creating tests for my project and I was wondering, is there a mocking package in ROS? I was using gtest for the tests itself so I was expecting gmock, or googlemock, to be in ROS too but I couldn't find it.. Should I just use gmock as if it was a regular gtest, without ROS?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

That would be great to have in a ROS context.

joq gravatar image joq  ( 2012-06-19 10:49:27 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
-1

answered 2012-08-04 00:36:57 -0600

afourast gravatar image

there is a simple interface for mocking subscribers , service and aciton servers .

http://www.ros.org/wiki/mock_objects

Hope that helps a little . Cheers

edit flag offensive delete link more

Comments

1

I need to mock something apart from subscribers, services and action servers.

kunaltyagi gravatar image kunaltyagi  ( 2014-12-06 08:00:53 -0600 )edit

Where can I find the sources of mock_objects?

thinwybk gravatar image thinwybk  ( 2017-06-19 14:13:37 -0600 )edit

Doesn't seem to exist anymore

Rufus gravatar image Rufus  ( 2020-11-24 02:54:25 -0600 )edit
3

answered 2012-08-03 11:38:25 -0600

tfoote gravatar image

It would be great to have. We have been working hard to keep from doing extra work. And currently mock is not available through our target platforms package managers. I expect it to become available in the future. At which point I'd expect us to start using it.

edit flag offensive delete link more

Comments

1

Have here been any updates related to mocking? I tried to modify the gtest.cmake in /opt/ros/indigo/share/catkin/cmake/test to make it generate a gmock library similar to gtest in <catkin_workspace>/build, but could not achieve anything. cmake is not one of my strengths.

kunaltyagi gravatar image kunaltyagi  ( 2014-12-06 07:26:47 -0600 )edit

Since Google Mock is not available (or is it in the 4 years since this post was made) on the target platform, what's the preferred way to mock certain functions when writing unit tests for ROS packages?

roboticom314 gravatar image roboticom314  ( 2016-07-22 16:14:04 -0600 )edit
1

The best practices method is to copy the entire google-mock module and link them manually unlike gtest, using your own functions. Look at the ROS's gtest cmake to get more idea on how to do that. And no official progress on the ROS-framework for Google-mock has been made AFAIK.

kunaltyagi gravatar image kunaltyagi  ( 2016-07-22 18:23:41 -0600 )edit

@tfoote are there plans to make core ros infrastructures such as Subscriber, Publisher, ActionClient, ActionServer, ServiceClient and ServiceServer (and their SimpleXXX variants) to implement interfaces so that we can create mocks ourselves using those interfaces?

Rufus gravatar image Rufus  ( 2020-11-24 02:56:43 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-06-19 02:56:44 -0600

Seen: 2,862 times

Last updated: Aug 04 '12