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

How to run tests on catkin installed packages?

asked 2020-11-02 00:55:13 -0500

achluomalus gravatar image

updated 2021-10-26 07:45:13 -0500

lucasw gravatar image

I'm pretty new to ROS, so my knowledge with ROS, catkin and, cmake is pretty basic. I have some questions on how should I proceed with the tests of my packages. The goal is to allow execution of each specific tests, but right now it's currently grouped (i.e, group-test-1, group-test-2, group-test-3, etc).

Here's the current setup:

  • Rostest is usable only in devel mode. I need to use install mode since it's the artifact that we're going to use in production.

  • I'm currently using catkin run_tests (i.e., catkin run_tests -Dgroup-test-1=on) to execute all tests for that group. I'm using options to group it, then have a foreach loop to create a test using add_rostest_gtest

  • It's not possible to run --gtest-filter since it also run some scripts

So far, here's what I think are the possible solutions:

  • Is it possible to use rostest in install mode? I haven't found a way to do it.

  • Does it make sense if I add options in my foreach loop so that I can use it this way "catkin run_test -Dgroup-test-1-specific-test-1=on", but I'm not sure if this will work.

    • ROS: Melodic
    • Catkin tools: 0.6.1
    • Python: 2.7.17
    • Cmake: 3.10.2
    • Gtest

I'm not sure if I'm in the right path. Any tips or advice will be really helpful.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-25 09:54:54 -0500

lucasw gravatar image

updated 2021-10-25 10:08:08 -0500

This #q307598 says to make the tests into a normal executables outside of the rostest infrastructure, but I think you can do this install (I'll update after I get it working or not)

install(DIRECTORY test/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/test)

also

install(PROGRAMS
  test/my_test.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

This installs the test file into two places though, but only the BIN destination one executes, to avoid that the .test files could be split up from the .py files they are coupled with into different directories.

edit flag offensive delete link more

Comments

I marked this as an answer, as I've done simular/the same things and worked out.

130s gravatar image 130s  ( 2022-08-26 16:30:50 -0500 )edit

Question Tools

Stats

Asked: 2020-11-01 23:14:12 -0500

Seen: 368 times

Last updated: Oct 26 '21