Ask Your Question
0

How to write ROS integration tests?

asked 2018-03-19 14:40:31 -0500

Cerin gravatar image

How do you write ROS integration tests, where you simulate a running node?

I've written some custom ROS nodes, and now I want to create some automated tests to confirm that they publish certain messages in response to receiving certain messages. These docs briefly mention integration tests and running tests "as a node", but they don't make any sense to me. The example given doesn't actually test the node, and only runs a toy self.assertEquals(1, 1).

For my test, I want to start roscore, several dependency nodes, my custom node, then publish messages, then wait N seconds for my node to publish its own messages, and fail if this doesn't happen. Is there any documentation on how to achieve this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-19 15:01:24 -0500

gvdhoorn gravatar image
edit flag offensive delete link more

Comments

That's is not an answer. Its a framework that has no examples on how to write a test

borgcons gravatar imageborgcons ( 2019-06-23 19:12:45 -0500 )edit

The first link under the Overview section is Writing rostests. Does that not provide sufficient information to at least get started?

gvdhoorn gravatar imagegvdhoorn ( 2019-06-24 01:42:38 -0500 )edit

No. It shows how to do gtest which is a unit test. An example of ROSTest(integration test) is not shown. Again the framework on how set set it up in the CMakefile.txt is shown but the actually writing of the test node is not.

borgcons gravatar imageborgcons ( 2019-06-24 04:02:52 -0500 )edit

The OP specifically asked:

For my test, I want to start roscore, several dependency nodes, my custom node, then publish messages, then wait N seconds for my node to publish its own messages, and fail if this doesn't happen.

rostest is how you do that. The rostest/Nodes page shows how to create .test files (essentially .launch files) that test what the OP appeared to ask for.

That's why I posted this answer.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-24 04:06:13 -0500 )edit

Yes it does , but it does not tell you how to create the tester node. The tester node would have to publish messages to get the test started. I would assume the tester node would also have to subscribe to the result to determine that it occurred. There is no example on how to publish or subscribe and check for the result.

borgcons gravatar imageborgcons ( 2019-06-24 04:24:07 -0500 )edit

I don't believe that's how it works.

The "tester nodes" in the examples are already provided as part of the Standard Test Nodes (here).

The tester node would have to publish messages to get the test started.

That depends on what is getting tested: if the node-under-test is a subscriber, you'd have to write a small node that publishes messages, yes. Nothing special about that I believe.

If the NUT is a publisher, the provided standard test nodes could be used, at least as a starting point.

See rostest/nodes/publishtest as an example fi.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-24 04:30:21 -0500 )edit

Now we are getting closer to an answer.

Using your above scenario if the node-under-test is a subscriber it would do some kind transformation/algorithm and output something. How would you know that the output is correct? In order fro an integration test to be valid you need to set up the test conditions and then verify that the results you are getting are correct. Having a test node publish the starting conditions is nothing special, but then you still have to verify the results.

borgcons gravatar imageborgcons ( 2019-06-24 04:47:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-19 14:40:31 -0500

Seen: 245 times

Last updated: Mar 19 '18