Basically, when I switched from `catkin_add_gtest` to `add_executable_with_gtest` to make sure the test is invoked only from a .test file, catkin_make no longer recompiles my cpp file with the tests. More detailed explanation below.
I'm trying to run some ROS unit and integration tests. For one of my tests, I added a node that subscribes to some bagged data and uses gtest to assert some simple conditions. Here's what my CMakeLists.txt snippet looked like:
if (CATKIN_ENABLE_TESTING)
find_package(GTest REQUIRED)
catkin_add_gtest(talker-test test/test_talker.cpp)
target_link_libraries(talker-test ${catkin_LIBRARIES})
find_package(rostest REQUIRED)
add_rostest(test/detection_test.test)
endif()
This runs fine. However, I want the test to subscribe to some data from a bag, so I want to run it from a test file. Here's what the test file looks like:
In order to make sure that my test runs through the .test file and not through my CMakeLists, I modified my CMakeLists file as follows:
if (CATKIN_ENABLE_TESTING)
find_package(GTest REQUIRED)
catkin_add_executable_with_gtest(talker-test test/test_talker.cpp)
target_link_libraries(talker-test ${catkin_LIBRARIES})
find_package(rostest REQUIRED)
add_rostest(test/detection_test.test)
endif()
This results in the behavior I desire (except for the bag running twice- once for each of my tests). But now, if I make changes to test_talker.cpp, running `catkin_make -DCATKIN_ENABLE_TESTING=true run_tests_test_pkg` does not recompile the cpp file. How can I make this happen?
↧