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

Based on @otamachan answer, this is my working configuration on Ubuntu 16.04 with ROS Kinetic, gtest (libgtest-dev v1.7.0-4ubuntu1) and gmock (google-mock v1.7.0-18092013-1):

# Tests
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # explicit gmock build (set these paths properly!)
  include_directories(/usr/include/gmock /usr/src/gmock)
  add_library(gmock /usr/src/gmock/src/gmock-all.cc)
  set(GMOCK_LIBRARIES gmock)

  add_rostest_gtest(my_test
    test/my_test.test
    src/test/my_test.cpp
    ...
  )

  target_link_libraries(my_test
    ${GMOCK_LIBRARIES}
    ${catkin_LIBRARIES}
  )
endif()

It seems that the problem has been simplified since gtest does not include gmock anymore.

Based on @otamachan answer, this is my working configuration on Ubuntu 16.04 with ROS Kinetic, gtest (libgtest-dev v1.7.0-4ubuntu1) and gmock (google-mock v1.7.0-18092013-1):

# Tests
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # explicit gmock build (set these paths properly!)
  include_directories(/usr/include/gmock /usr/src/gmock)
  add_library(gmock add_library(libgmock /usr/src/gmock/src/gmock-all.cc)
  set(GMOCK_LIBRARIES gmock)

  add_rostest_gtest(my_test
    test/my_test.test
    src/test/my_test.cpp
    ...
  )

  target_link_libraries(my_test
    ${GMOCK_LIBRARIES}
libgmock
    ${catkin_LIBRARIES}
  )
endif()

It seems that the problem has been simplified since gtest does not include gmock anymore.

Based on @otamachan answer, this is my working configuration on Ubuntu 16.04 with ROS Kinetic, gtest (libgtest-dev v1.7.0-4ubuntu1) and gmock (google-mock v1.7.0-18092013-1):

# Tests
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # explicit gmock build (set these paths properly!)
  include_directories(/usr/include/gmock /usr/src/gmock)
  add_library(libgmock /usr/src/gmock/src/gmock-all.cc)

  add_rostest_gtest(my_test
    test/my_test.test
    src/test/my_test.cpp
    ...
  )

  target_link_libraries(my_test
    libgmock
    ${catkin_LIBRARIES}
  )
endif()

It seems that the problem has been simplified since gtestgmock does not include gmockgtest anymore.

Based on @otamachan answer, this is my working configuration on Ubuntu 16.04 with ROS Kinetic, gtest (libgtest-dev v1.7.0-4ubuntu1) and gmock (google-mock v1.7.0-18092013-1):

# Tests
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # explicit gmock build (set these paths properly!)
  include_directories(/usr/include/gmock /usr/src/gmock)
  add_library(libgmock /usr/src/gmock/src/gmock-all.cc)

  add_rostest_gtest(my_test
    test/my_test.test
    src/test/my_test.cpp
    ...
  )

  target_link_libraries(my_test
    libgmock
    ${catkin_LIBRARIES}
  )
endif()

It seems that the problem has been simplified since gmock does not include gtest anymore.


EDIT: as shown in the launchpad, the google-mock package for Ubuntu Xenial depends on libgtest-dev (>= 1.6.0). Actually it does not includes gtest even since Ubuntu 14.10 (Utopic Unicorn). Unfortunately, Ubuntu 14.04 is shipped with google-mock v1.6.0+svn437-0ubuntu5 (see the package) which includes gtest inside; indeed, it depends on nothing but python.

Based on @otamachan answer, this is my working configuration on Ubuntu 16.04 with ROS Kinetic, gtest (libgtest-dev v1.7.0-4ubuntu1) and gmock (google-mock v1.7.0-18092013-1):

# Tests
if(CATKIN_ENABLE_TESTING)
  find_package(rostest REQUIRED)

  # explicit gmock build (set these paths properly!)
  include_directories(/usr/include/gmock /usr/src/gmock)
  find_library(GMOCK_LIBRARIES libgmock)
  if(NOT GMOCK_LIBRARIES)
    add_library(libgmock /usr/src/gmock/src/gmock-all.cc)
  endif()

  add_rostest_gtest(my_test
    test/my_test.test
    src/test/my_test.cpp
    ...
  )

  target_link_libraries(my_test
    libgmock
    ${catkin_LIBRARIES}
  )
endif()

It seems that the problem has been simplified since gmock does not include gtest anymore.


EDIT: as shown in the launchpad, the google-mock package for Ubuntu Xenial depends on libgtest-dev (>= 1.6.0). Actually it does not includes gtest even since Ubuntu 14.10 (Utopic Unicorn). Unfortunately, Ubuntu 14.04 is shipped with google-mock v1.6.0+svn437-0ubuntu5 (see the package) which includes gtest inside; indeed, it depends on nothing but python.


EDIT2: added a simple check to avoid multiple add_library(libgmock ...) from distinct packages.