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

Can you write unittests that use the parameter server?

asked 2015-10-16 06:40:57 -0500

Felix Duvallet gravatar image

updated 2015-10-16 06:43:52 -0500

I'm trying to write unittests (in python) that use the parameter server. I'd like to load some parameters from a test yaml file, and use something like the rospy.get_param() functionality.

The code under test parses information stored as ros parameters, so I to provide test input that is as close as possible to the result of get_param.

In particular, is it possible to:

  1. Run unit tests without depending/conflicting with the master parameter server (roscore may not necessarily be running)?
  2. Load parameters from a test.yaml file?
  3. Clear the parameter server between different unit tests? (to ensure each test is stateless)

I am aware the rosparam module can load parameters from a file, but it returns a list of dictionaries instead of loading the parameters into the param server (and the returned data is not compatible with get_param).

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2020-12-13 09:46:22 -0500

junya gravatar image

I run dummy parameter server on unittest. See my implementation:

edit flag offensive delete link more

answered 2020-11-25 00:45:20 -0500

Tahir M. gravatar image

updated 2020-11-25 05:01:37 -0500

Unittest are meant to test your libraries a ROS free code(Checkout here in 6. Levels of testing) may be only in Python and C++. So theoretically they should not depend on ROS related libraries. For unittest you can take the parameters as input from a yaml file. To answer your questions:

  1. Parameter server at the moment is part of roscore. So without running roscore it is not possible.

  2. Yes without roscore input from a file, or with upload them to parameter server after running roscore and now take the information now from parameter server.

  3. Yes but not a good idea how about grouping the similar tests in test suites for consistency. A nice idea would be to follow AAA Cycle

edit flag offensive delete link more

answered 2020-11-23 17:58:29 -0500

sebmascha gravatar image

Check I do integration test that uses the parameter server. I load params using .yaml

edit flag offensive delete link more

Question Tools



Asked: 2015-10-16 06:40:57 -0500

Seen: 743 times

Last updated: Dec 13 '20