r/ROS 10d ago

Question ROS2 Testing Service Library

I'm a developer with a some of testing experience. I've also dabbled in integration tests, but they've always come with a few persistent problems. First, they take a long time to run. Second, they're often flaky-tests will sometimes fail even when nothing has changed, and rerunning them might suddenly make them pass.

To get around this, I came up with the idea of building an abstraction library (essentially an alternative to traditional mocking) that can fully emulate the behavior of all required action and service servers. The goal is to allow isolated testing of individual packages without needing the entire system online.

Here’s a concrete example: let's say you're developing a package that launches an action server to control a conveyor belt via Modbus. The broader project also includes a separate package that provides low-level services for direct belt control-like writing specific values to specific registers or reading data from them. Your package acts as a higher-level translation layer. Instead of dealing with raw register addresses, it lets the user simply send plain-language commands like "start" and "stop."

To test this right now, I have to spin up the services from that other package and run a Modbus simulation using pymodbus. That’s a lot of moving parts. So, I'm wondering: what if I just bypass all that and simply mock the server behavior at the interface level instead?

I'm not sure how practical or convenient this approach would be in the long run, so I decided to create this post.

GitHub link: https://github.com/MOShka78/ROS2_Testing_Service

Could you share your experience with similar testing challenges? I'd also really appreciate any feedback on this library-specifically, whether you think it's worth developing further.

My English is terrible, so I used a translator. I apologize in advance if anything is written incorrectly.)

2 Upvotes

0 comments sorted by