Robotics StackExchange | Archived questions

Can you write unittests that use the parameter server?

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).

Asked by Felix Duvallet on 2015-10-16 06:40:57 UTC

Comments

Answers

Check http://wiki.ros.org/rostest I do integration test that uses the parameter server. I load params using .yaml

Asked by sebmascha on 2020-11-23 18:58:29 UTC

Comments

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

Asked by Tahir M. on 2020-11-25 01:45:20 UTC

Comments

I run dummy parameter server on unittest. See my implementation: https://github.com/groove-x/mqtt_bridge/pull/37

Asked by junya on 2020-12-13 10:46:22 UTC

Comments