Repository Summary
Checkout URI | https://github.com/tecnalia-advancedmanufacturing-robotics/rostest_node_interface_validation.git |
VCS Type | git |
VCS Version | melodic-devel |
Last Updated | 2020-11-04 |
Dev Status | MAINTAINED |
Released | RELEASED |
Tags | No category tags. |
Contributing |
Help Wanted (-)
Good First Issues (-) Pull Requests to Review (-) |
Packages
Name | Version |
---|---|
rostest_node_interface_validation | 0.2.0 |
README
rostest_node_interface_validation
The package rostest_node_interface_validation
extends rostest
to add more testing functionalities at node level.
Author & Maintainer: Anthony Remazeilles, anthony.remazeilles@tecnalia.com
Affiliation : Tecnalia Research and Innovation, Spain
License: This project is under the Apache 2.0 License. See LICENSE.md for more details.
Getting started
Prerequisites
We assume ROS
is installed on the machine.
Code developed and tested so far under ROS kinetic
.
Installing
# Assuming ~/catkin_ws is the workspace in which the repository has been downloaded
cd ~/catkin_ws
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO
Use
This package contains two scripts, test_service
and test_filter
.
We just highlight the typical usage:
test_service
An example is provided in service_call.test:
<launch>
<!-- Following node is a basic service server -->
<node pkg="rostest_node_interface_validation" type="service_server.py" name="service_server"/>
<!-- configuration of the test-->
<test test-name="test_service" pkg="rostest_node_interface_validation" type="test_service" >
<rosparam>
calls:
- name: /trigger_spec
input: None
output: {'success': True, 'message': 'well done!'}
</rosparam>
</test>
</launch>
where:
-
name
: is the service to test -
input
: input parameters, defined as a dictionary -
output
: expected output, defined as a dictionary
The test will connect to the service indicated, call it with the provided parameters, and compare the output received with the one defined. The test succeeds if all went well.
Services with no input messages should use term None
for the input value, as illustrated above.
Another example can be generated if rospy_tutorial
is installed.
If one creates the following example example_srv.test
file:
<launch>
<test test-name="test_service" pkg="rostest_node_interface_validation" type="test_service" >
<rosparam>
calls:
- name: /add_two_ints
input: {'a': 0, 'b': 5.0}
output: {'sum': 5}
</rosparam>
</test>
</launch>
# in shell 1
roscore
# in shell 2
rosrun rospy_tutorials add_two_ints_server
# in shell 3 (adjust rostest_node_interface_validation to the package where the test file is placed)
rostest rostest_node_interface_validation example_srv.test
test_filter
test_filter
enables testing a filter-like node, that is supposed to publish a message after having processed a received message.
An example is provided in msg_filter.test:
File truncated at 100 lines see the full file