More info about unit / integration testing for new bindings

110 views
Skip to first unread message

jdb...@diversit.eu

unread,
Apr 8, 2014, 1:32:55 AM4/8/14
to ope...@googlegroups.com
Hi,

I am working on a binding to control my Marantz SR7007 AV receiver. The goal is to create a general purpose controller.
Since I'm used to work TDD I am looking into how to properly unit/integration test this binding. I cannot find any information about this. 
Can someone provide more info about how to do proper unit and/or integration testing?

I first tried to add test cases in the binding project, as you would do for any other project, but then saw that other bindings had seperate binding-test projects.
For now I copied one of those and adapted it a bit. Since there is a Maven archetype for creating a binding project, should there not also be an archetype to properly setup a new test project for a binding?

ps. For those interested: my development is in https://github.com/diversit/openhab. I'm using Scala to implement the binding which was a bit of a hassle to setup but works fine now.
pps. I created a mock tcp-service for integration testing/simulation which I will share on Github soon.

Regards,
Joost den Boer

Kai Kreuzer

unread,
Apr 16, 2014, 3:54:17 AM4/16/14
to ope...@googlegroups.com
Hi Joost,

Thanks for your input! Unfortunately, you are right that there is a very low test coverage on the existing code base and specifically on bindings.
As you noticed, the tests that are there are put in OSGi fragments. This is a best practice for testing in OSGi when you need to execute tests with the OSGi framework started (see http://rcpquickstart.wordpress.com/2007/06/20/unit-testing-plug-ins-with-fragments/).

I would like to also add a test fragment skeleton to the Maven archetype. I’ll probably go for this for openHAB 2.0 as quite a few things will change there for the binding structure. openHAB 2.0 will make use of Eclipse SmartHome and we have introduced a test support framework in there just this week - see details on https://wiki.eclipse.org/EclipseSmartHome/Development/UnitTesting. This framework uses Groovy to allow to write short and concise tests while easily adding support for OSGi service handling etc.

In general I see the biggest challenge for testing bindings in the fact that they highly depend on external things (i.e. the devices or web services). This is usually very difficult to mock (as you would have to simulate major parts of its behavior) and to isolate from the logic (i.e. if you communicate through a serial port, you will have to add an additional indirection layer here).

So please share any insights and ideas you may have here. I am also interested in your mock tcp-service for the testing infrastructure.

Best regards,
Kai


--
You received this message because you are subscribed to the Google Groups "openhab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openhab+u...@googlegroups.com.
To post to this group, send email to ope...@googlegroups.com.
Visit this group at http://groups.google.com/group/openhab.
For more options, visit https://groups.google.com/d/optout.

bernard Rodriguez

unread,
Sep 14, 2015, 4:57:04 PM9/14/15
to openhab
hi Joost,
Do you have a working binding for marrantz SR7007 ?
I would be interested in it .
Regardz 
Bernard
Reply all
Reply to author
Forward
0 new messages