ros2 difference between colcon test and launch_test
What are appropriate use cases for each one?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
What are appropriate use cases for each one?
launch_test
is a command that is provided by the launch_testing
package. It can be used to run tests that are described/set up using a launch file, e.g.
$ launch_test path/to/my_launch_test.py
The test must be set up in a very specific way. The Python launch file must define a generate_test_description()
function that returns a LaunchDescription
. I don't think this file needs to be part of a package; it might be able to just be a standalone file. For example:
def generate_test_description():
return launch.LaunchDescription([
launch.actions.ExecuteProcess(
cmd=[path_to_process],
),
# Start tests right away - no need to wait for anything in this example.
# In a more complicated launch description, we might want this action happen
# once some process starts or once some other event happens
launch_testing.actions.ReadyToTest()
])
See this README: https://github.com/ros2/launch/blob/3....
colcon test
is a command that runs all tests for a given package (or given packages): C++ tests (e.g. defined as a CMake test in a CMakeLists.txt
using ament_add_gtest(...)
), or Python tests (e.g. defined as a CMake test in a CMakeLists.txt
using ament_add_pytest_test(...)
or just a Python file under a test/
directory in a pure Python package). E.g.
$ colcon test --packages-select my_package
Some of those Python test files can be launch tests similar to the example above, but the generate_test_description()
function has to be annotated with @pytest.mark.launch_test
for the test file to be run properly. I think in this case the same file can also be run using launch_test
.
In general, you can simply just use colcon test
to run your tests.
Asked: 2021-04-26 10:03:40 -0500
Seen: 833 times
Last updated: Apr 26 '21
ROS2 SLAM_Toolbox Failed Colcon Build
how to create and build pakages in ROS2 CRYSTAL..is there any need to use AMENT tools in CRYSTAL..
Cannot build package due to pkg_resources.extern.packaging.version.InvalidVersion
How to get argument values in ROS2?
[Nav2] Why use Voxel layer over 2D layer for RGBD sensor?
ROS2 xacro parsing: ${robot_ip} vs $(arg robot_ip)
[ros2run]: Process exited with failure 1
ROS2 launch FindPackageShare vs get_package_share_directory
[ROS2] I can publish a parameter with wrong type and get no exception