ros2 test_error ai_generated true

colcon test: Failed to find test dependencies: 'python3-pytest', 'ros_testing' not installed

ID: ros2/colcon-test-failure-test-dependencies-not-installed

Also available as: JSON · Markdown · 中文
88%Fix Rate
85%Confidence
1Evidence
2024-01-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Humble active
Iron active
Rolling active

Root Cause

colcon test requires test dependencies specified in package.xml (under <test_depend>) to be installed in the workspace. Missing system or ROS packages cause test execution to fail.

generic

中文

colcon test需要安装package.xml中指定的测试依赖项(位于<test_depend>下)。缺少系统或ROS包会导致测试执行失败。

Official Documentation

https://docs.ros.org/en/rolling/Tutorials/Beginner-Client-Libraries/Writing-A-Simple-Py-Package.html#test-your-package

Workarounds

  1. 90% success Install test dependencies explicitly: rosdep install --from-paths src --ignore-src -r -y --rosdistro humble --include-test-dependencies. Then run colcon test again.
    Install test dependencies explicitly: rosdep install --from-paths src --ignore-src -r -y --rosdistro humble --include-test-dependencies. Then run colcon test again.
  2. 85% success For missing system packages like python3-pytest, install manually: sudo apt-get install python3-pytest. For ROS packages like ros_testing: sudo apt-get install ros-humble-ros-testing.
    For missing system packages like python3-pytest, install manually: sudo apt-get install python3-pytest. For ROS packages like ros_testing: sudo apt-get install ros-humble-ros-testing.
  3. 70% success If test dependencies are optional, temporarily remove them from package.xml and run colcon test with --packages-skip-build-failed to skip problematic packages.
    If test dependencies are optional, temporarily remove them from package.xml and run colcon test with --packages-skip-build-failed to skip problematic packages.

中文步骤

  1. Install test dependencies explicitly: rosdep install --from-paths src --ignore-src -r -y --rosdistro humble --include-test-dependencies. Then run colcon test again.
  2. For missing system packages like python3-pytest, install manually: sudo apt-get install python3-pytest. For ROS packages like ros_testing: sudo apt-get install ros-humble-ros-testing.
  3. If test dependencies are optional, temporarily remove them from package.xml and run colcon test with --packages-skip-build-failed to skip problematic packages.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    The error will still occur for the selected package if dependencies are missing. The --packages-select flag doesn't bypass dependency resolution.

  2. 85% fail

    This command by default skips test dependencies unless --rosdistro and --include-test-dependencies are specified.