ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A

ROS2 - gtest


I am moving my project to ROS2 and found out that gtest of ros2 is older than was was used with ROS1. This is problematic as I am using “TYPED_TEST_SUITE” and that is only in newer releases.

For context: I was using ROS1 noetic and switching to ROS2 foxy.

How to handle this? I wonder what is “correct” way to get more modern gtest

1 Like

This repository dictates which version is used in ROS 2:

I would open an issue/pull requests there.

Note, however, we’re not likely to do this in Foxy since it needs to be ABI stable (though googletest is kind of special since we don’t use it in our applications as much and it is built from source in each package).

Either way, discussing it on the issue tracker is the right place.

What does “our applications” mean here?

I mean our packages don’t export libraries or executables that depend on gtest much (if at all). Mostly, a copy of googletest is built in the package and linked against our tests, which are not installed. So, though we use googletest/googlemock all over the place, it’s unlikely to affect our ABI stability.

I still think we’d decline to upgrade the version in place in foxy, but I was just saying, it’s not a normal dependency.

1 Like

I understand, but maybe answer for the problem itself is better served here than in issue:

Is there a sane/easy way to use more modern gtest in my ros package? I don’t really mind to use system dependency or to download it as external project. Basically, how to change the ‘ament_add_gtest’ so it uses the correct version I want (I suppose that is the right place to solve the problem?)

There’s no way to use your “own” copy of googletest with ament_add_gtest (as far as I know right now).

That issue tracker is still the best place to discuss it, in my opinion.

As an aside, I setup a non-ament/non-ros cmake project to expose googletest to your package here:

The idea is that it could be the backing for ament_add_gtest as well as other things like ignition packages and other low level things that come “before” ROS or ignition in the dependency graph, but it hasn’t really taken off except for in a few isolated cases.

It provides multiple versions of googletest at a time, using a different mechanism from ament_cmake.