Skip to content

Commit

Permalink
update tests to launch_testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hsd-dev committed Nov 8, 2023
1 parent 242b902 commit 269456a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/pf_description/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ project(pf_description)
find_package(ament_cmake REQUIRED)

if(BUILD_TESTING)
find_package(rostest REQUIRED)
add_rostest(tests/test_r2000_bringup.launch)
add_rostest(tests/test_r2300_bringup.launch)
find_package(launch_testing_ament_cmake REQUIRED)
add_launch_test(tests/test_r2000_bringup.launch.py)
add_launch_test(tests/test_r2300_bringup.launch.py)
endif()

install(DIRECTORY launch meshes rviz urdf DESTINATION share/${PROJECT_NAME})
Expand Down
2 changes: 2 additions & 0 deletions src/pf_description/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<test_depend>launch_testing</test_depend>


<export>
<build_type>ament_cmake</build_type>
Expand Down
6 changes: 0 additions & 6 deletions src/pf_description/tests/test_r2000_bringup.launch

This file was deleted.

27 changes: 27 additions & 0 deletions src/pf_description/tests/test_r2000_bringup.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from ament_index_python import get_package_share_directory
import launch
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
import launch_testing
import os
import pytest

@pytest.mark.rostest
def generate_test_description():

launch_desc = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
os.path.join(get_package_share_directory("pf_description"), "launch"),
"/pf_bringup.launch.py",
]
)
)

ready_to_test = launch.actions.TimerAction(
period=5.0,
actions=[launch_testing.actions.ReadyToTest()],
)

return (LaunchDescription([launch_desc, ready_to_test]), {})
6 changes: 0 additions & 6 deletions src/pf_description/tests/test_r2300_bringup.launch

This file was deleted.

28 changes: 28 additions & 0 deletions src/pf_description/tests/test_r2300_bringup.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from ament_index_python import get_package_share_directory
import launch
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
import launch_testing
import os
import pytest

@pytest.mark.rostest
def generate_test_description():

launch_desc = IncludeLaunchDescription(
PythonLaunchDescriptionSource(
[
os.path.join(get_package_share_directory("pf_description"), "launch"),
"/pf_bringup.launch.py",
]
),
launch_arguments = {'scanner': 'r2300'}.items()
)

ready_to_test = launch.actions.TimerAction(
period=5.0,
actions=[launch_testing.actions.ReadyToTest()],
)

return (LaunchDescription([launch_desc, ready_to_test]), {})

0 comments on commit 269456a

Please sign in to comment.