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

edit retag close merge delete

Sort by » oldest newest most voted

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

more

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

more

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

more