Why does launch_test result show "Ran 0 tests in 0.000 s" after running a test?

asked 2023-06-22 14:48:53 -0500

lexi gravatar image

I am trying to write an integration test to test the ROS API of a node I am working on, and I followed some of the examples from the launch and launch_ros repos that use the launch_test tool.

The final output shows that 0 tests ran though, even though earlier up in the output I can see that it ran my test and it shows "Ran 1 test in 7.600s".

Is there anyway to stop it from printing "Ran 0 tests in 0.000s" at the end? And is there any way to get a cleaner output from launch_test that only shows the test result and not all the logging output from the test?

This is my test:

import pytest
from launch import LaunchDescription
from launch_ros.actions import Node
import rclpy
import unittest
from evergreen_cvml.instance_seg_service_client import InstanceSegServiceClient
from evergreen_common.topic_names import LEFT_REAR_CAMERA_LEFT_IMAGE_TOPIC
from rclpy.callback_groups import ReentrantCallbackGroup
from launch_testing.actions import ReadyToTest

import launch_ros.actions
import launch.launch_service
import launch_testing.io_handler

# Note: This test is trying to follow the launch_testing_ros pattern
# See this file for an example: https://github.com/ros2/launch_ros/blob/57362f296f600d46f140b084c14f04b241988d1d/launch_testing_ros/test/examples/talker_listener_launch_test.py


@pytest.mark.rostest
def generate_test_description() -> tuple[LaunchDescription, dict]:
    image_publisher = Node(
        package='evergreen_cvml',
        executable='image_publisher.py',
        name='image_publisher',
        output='log'
    )
    cvml_node = Node(
        package='evergreen_cvml',
        executable='cvml_engine.py',
        name='cvml_engine',
        output='log'
    )
    return (
        LaunchDescription([
            cvml_node,
            image_publisher,
            ReadyToTest()
        ]),
        {
            'cvml_node': cvml_node,
            'image_publisher': image_publisher
        }
    )


class TestTalkerListenerLink(unittest.TestCase):

    @classmethod
    def setUpClass(cls) -> None:
        # Initialize the ROS context for the test node
        rclpy.init()

    @classmethod
    def tearDownClass(cls) -> None:
        # Shutdown the ROS context
        rclpy.shutdown()

    def setUp(self) -> None:
        # Create a ROS node for tests
        self.node = rclpy.create_node('test_cvml_node')

    def tearDown(self) -> None:
        self.node.destroy_node()

    def test_instance_seg(self,
                          launch_service: launch.launch_service.LaunchService,
                          cvml_node: launch_ros.actions.node.Node,
                          proc_output: launch_testing.io_handler.ActiveIoHandler) -> None:
        self.node.get_logger().info('Testing instance segmentation service')

        # Create service client to call the service
        client = InstanceSegServiceClient(
            self.node, LEFT_REAR_CAMERA_LEFT_IMAGE_TOPIC, ReentrantCallbackGroup())
        seg_result = client.request()
        self.assertIsNotNone(seg_result)

And the output from running it:

Blockquote lexiwinters@easybake-mini:~/workspace/evergreen/ros_ws$ launch_test src/evergreen_cvml/test/test_instance_seg_service.py test_instance_seg (test_instance_seg_service.TestTalkerListenerLink) ... [INFO] [cvml_engine.py-1]: process started with pid [1482800] type of cvml_node: <class 'launch_ros.actions.node.node'=""> type of proc_output: <class 'launch_testing.io_handler.activeiohandler'=""> type of launch_service: <class 'launch.launch_service.launchservice'=""> [cvml_engine.py-1] /home/lexiwinters/.local/lib/python3.10/site-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3483.) [cvml_engine.py-1] return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] ok


Ran 1 test in 7.600s

OK [image_publisher.py-2] Traceback (most recent call last): [image_publisher.py-2] File "/home/lexiwinters/workspace/evergreen/ros_ws/install/evergreen_cvml/lib/evergreen_cvml/image_publisher.py", line 48, in <module> [image_publisher.py-2] main() [image_publisher.py-2] File "/home/lexiwinters/workspace/evergreen/ros_ws/install/evergreen_cvml/lib/evergreen_cvml/image_publisher.py", line 43, in main [image_publisher.py-2] rclpy.spin(node) [image_publisher.py-2] File "/opt/ros/humble ... (more)

edit retag flag offensive close merge delete