https://github.com/abaeyens/ros2-integration-testing-examples
ROS 2 integration and unit testing examples featuring colcon, launch_testing and ament_cmake_ros
https://github.com/abaeyens/ros2-integration-testing-examples
ament ament-cmake-ros cmake colcon example integration-testing launch-testing ros2 tutorial xunit
Last synced: about 23 hours ago
JSON representation
ROS 2 integration and unit testing examples featuring colcon, launch_testing and ament_cmake_ros
- Host: GitHub
- URL: https://github.com/abaeyens/ros2-integration-testing-examples
- Owner: abaeyens
- License: mit
- Created: 2024-10-13T12:45:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-26T10:54:13.000Z (about 1 year ago)
- Last Synced: 2025-01-26T11:25:47.621Z (about 1 year ago)
- Topics: ament, ament-cmake-ros, cmake, colcon, example, integration-testing, launch-testing, ros2, tutorial, xunit
- Language: Python
- Homepage: https://arnebaeyens.com/blog/2024/ros2-integration-testing/
- Size: 8.79 KB
- Stars: 20
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ROS 2 Integration and Unit Testing Examples
An example package `app` that showcases
integration testing with `launch_testing` and `ament_cmake_ros`
and unit testing with `pytest` and `gtest`.
Both integration and unit tests write out **complete XUnit reports**,
allowing to list the results of all individual tests together
(e.g. to create a report as part of a CI/CD pipeline).
Also, each integration test automatically receives a unique `ROS_DOMAIN_ID`
to avoid crosstalk between simultaneously running tests.
A ROS 2 Jazzy Docker setup is included to get started quickly.
This code probably also works on Humble and Iron.
Please see the instructions further on for creating the `.env` file.
For more documentation, please have a look at the code files
in the `app` package such as
[test_integration.py](src/app/test/test_integration.py)
and the [CMakeLists.txt](src/app/CMakeLists.txt)
## Get up and running
```bash
git clone git@github.com:abaeyens/ros2-integration-testing-examples.git
cd ros2-integration-testing-examples
echo -e USER_ID=$(id -u $USER)\\nGROUP_ID=$(id -g $USER) >> .env
docker compose build --pull
docker compose run --rm app bash
colcon build
source install/setup.bash
colcon test --event-handlers console_direct+
colcon test-result --all
xunit-viewer -r build/app/test_results -c
```
## Notes
- The tests include launching a turtlesim GUI,
hence the tests may fail on a headless system.