ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ament_add_gtest_executable only calls add_executable() and links the target against the gtest libraries. It does not register the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake#L16-L19)

What you want instead is ament_add_gtest. This macro calls add_executable(), links the target against the gtest libraries, and registers the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest.cmake#L16-L19)


For completeness, if you were using ament_add_gtest_executable, you would have to supplement it with a call to ament_add_gtest_test, which registers an executable created with ament_add_gtest_executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_test.cmake#L16-L19)

ament_add_gtest_executable only calls add_executable() and links the target against the gtest libraries. It does not register the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake#L16-L19)

What you want instead is ament_add_gtest. This macro calls add_executable(), links the target against the gtest libraries, and registers the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest.cmake#L16-L19)


For completeness, if you were using ament_add_gtest_executable, you would have to supplement it with a call to ament_add_gtest_test, which registers an executable created with ament_add_gtest_executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_test.cmake#L16-L19)

So you either do:

ament_add_gtest(driverobot_test
    test/driverobot_test.cpp
)

or

ament_add_gtest_executable(driverobot_test
    test/driverobot_test.cpp
)
ament_add_gtest_test(driverobot_test)

ament_add_gtest_executable only calls add_executable() and links the target against the gtest libraries. It does not register the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_executable.cmake#L16-L19)

What you want instead is ament_add_gtest. This macro calls add_executable(), add_executable(), links the target against the gtest libraries, and registers the executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest.cmake#L16-L19)


For completeness, if you were using ament_add_gtest_executable, you would have to supplement it with a call to ament_add_gtest_test, which registers an executable created with ament_add_gtest_executable as a test. (Check https://github.com/ament/ament_cmake/blob/2bf27ce5ad01af340e1f4efd44232c1067d0dbda/ament_cmake_gtest/cmake/ament_add_gtest_test.cmake#L16-L19)

So you either do:

ament_add_gtest(driverobot_test
    test/driverobot_test.cpp
)

or

ament_add_gtest_executable(driverobot_test
    test/driverobot_test.cpp
)
ament_add_gtest_test(driverobot_test)