[ros-users] [Discourse.ros.org] [Next Generation ROS] Design By Contract

fkromer ros.discourse at gmail.com
Thu Oct 12 09:14:55 UTC 2017

[quote="iluetkeb, post:34, topic:2405"]
I also once had a case with parameters, where the combination of two parameters resulted in an out-of-range condition.

Right, that are typical cases for combinatorial ROS node unit tests. However often it can be hard to guess the right samples of combinations for input data (parameters, received topic messages, service requests, action requests) for tests in advance. It can be easier to define property based tests which can be setup to execute the tests with all combinations of input data and decide later if the input data for failing tests are actually invalid or if they are ok (and exclude them from further test executions to prevent from false positives if applicable). However I do not know about the current state of property based unit testing of nodes in ROS. Some of @asmodehn projects use [hypothesis](http://hypothesis.works) which is a property based testing framework for Python already but I don't know how it is used in detail yet:

[quote="asmodehn, post:27, topic:2405"]
Quick replies :

* pyros-test is MIT or BSD, along these lines, I just havent taken the time to put a file there I ll try to do it soon.
* python makes things simpler than C++ as there are defacto standard test frameworks. So I am trying to support whatever basic python and ROS support ( unittest, doctest, and nose ) and pytest. unittest already includes a mock library by the way in python3, which is just the mock library in python2 .
* pyros-test is currently very very simple (probably too simple to need a separate package), and Id like to eventually improve it when I get the chance

But IMHO you re probably better of extracting what I already started in https://github.com/pyros-dev/pyros-msgs and https://github.com/pyros-dev/pyros-schemas : have a look at property based testing and hypothesis, it should be simple enough to automatically generate fake nodes based on an existing message definition and then send fake messages around :slight_smile: .

Some example of hypothesis use here : https://github.com/pyros-dev/pyros-schemas/blob/nested_merged/tests/test_pyros_schemas/hypothesis_example.py and an example of generating messages with it there https://github.com/pyros-dev/pyros-schemas/blob/nested_merged/tests/test_pyros_schemas/test_basic_fields.py

[quote="iluetkeb, post:34, topic:2405"]
You can use roswtf during runtime, it will report subscriptions that have no publisher, and also type mismatches.

The thing is, you never know whether a subscription might be optional, and there are also cases where either one or the other subscription can be used, but not both.

Again, I agree this would be useful to check. Weve so far called such things graph consistency checks.

Thanks for that hint. (I thought about to wrap some ROS command line tool functionalities to find graph inconsistencies into a ROS node, run the node during node integration which asserts with error log messages if the graph would be inconsistent.)

[quote="iluetkeb, post:34, topic:2405"]
The video-link is here: https://vimeo.com/236186712

I have since published the related code at https://github.com/bosch-robotics-cr/tracetools, but be aware that its not very useful without our instrumentation of roscpp. Im also in the process of publishing that, but not quite there, yet.

Thanks a lot. I am looking forward to it.

[quote="iluetkeb, post:34, topic:2405"]
Well, yes, you could, but thats why I would prefer to put those specs (at least in part) onto the resulting system.

Right. Makes sense.

[Visit Topic](https://discourse.ros.org/t/design-by-contract/2405/35) or reply to this email to respond.

More information about the ros-users mailing list