Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

rostest - Minimum Working Example

I'm having developing tests for a package with catkin, specifically tests that run within a launch file using C++/gtest.

You can download my files here.

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(davidscheck)

find_package(catkin REQUIRED COMPONENTS roscpp)

catkin_package()

include_directories(
  ${catkin_INCLUDE_DIRS}
)

find_package(rostest REQUIRED)
find_package(gtest)

add_rostest_gtest(tests_mynode test/alaunch.launch test/mytest.cpp)
target_link_libraries(tests_mynode ${catkin_LIBRARIES} ${GTEST_LIBRARIES})

test/alaunch.launch

<launch>
 <test test-name="test_mynode" pkg="davidscheck" type="test_mynode" />
</launch>

teset/mytest.cpp

#include <gtest/gtest.h>

TEST(DavidsTester, basicTest){
  EXPECT_TRUE(true);
}

int main(int argc, char** argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Problem: The executable is not being built.

Note that I do want it to run within the launch file, so adding catkin_add_gest will not work.

rostest - Minimum Working Example

I'm having problems developing tests for a package with catkin, specifically tests that run within a launch file using C++/gtest.

You can download my files here.

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
project(davidscheck)

find_package(catkin REQUIRED COMPONENTS roscpp)

catkin_package()

include_directories(
  ${catkin_INCLUDE_DIRS}
)

find_package(rostest REQUIRED)
find_package(gtest)

add_rostest_gtest(tests_mynode test/alaunch.launch test/mytest.cpp)
target_link_libraries(tests_mynode ${catkin_LIBRARIES} ${GTEST_LIBRARIES})

test/alaunch.launch

<launch>
 <test test-name="test_mynode" pkg="davidscheck" type="test_mynode" />
</launch>

teset/mytest.cpp

#include <gtest/gtest.h>

TEST(DavidsTester, basicTest){
  EXPECT_TRUE(true);
}

int main(int argc, char** argv){
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Problem: The executable is not being built.

Note that I do want it to run within the launch file, so adding catkin_add_gestcatkin_add_gtest will not work.