Testing own binding

Tags: #<Tag:0x00007f616f75b4d0> #<Tag:0x00007f616f75b2f0> #<Tag:0x00007f616f75b138>

I wrote my OpenHab binding, but before releasing it I want to test it. I tried to write some JUnits (i.e. SuplaTokenTest), but when I run mvn clean test none of test are run.

Could you point me some documentation about writing unit test for OH bindings?

The command for the “Static Code Analysis Tool” is “mvn clean install”. You need to run this command from the root directory of your binding ( should be something like: “…/binding/org.openhab.binding.supla”).
That way a .jar is created and you get feedback on possible syntax-problems in your code, all to be found in the newly created Directory …/target with your bindings folder.

https://eclipse.org/smarthome/documentation/development/testing.html

Static code analyses and tests are different :wink: .

Sorry for the false direction.
:blush: There is always something to learn.

I saw this link, but it still does not solve my problem.

First - should JUnits be write in my binding or in test binding?
Second - creating skeleton for test does not work for OH

Personally, I add them into the binding rather than a separate binding, but I don’t think that’s how the system is designed and you need to be careful not to have them combined into the JAR. I do it this way for specific reasons to do with the way my bindings are structured (ie outside of the main repo).

If you have them as separate bundles, have you updated the parent pom to include this bundle as well as your binding bundle?

Please look at this test. I have it in my binding under src/test/java everything compiles OK, but when I run mvn clean test this test is not invoked. What could be a reason of this behavior?

My guess is that the tests don’t run without the appropriate additions to the POM. I know I had to add this to the zwave/zigbee bundles, and as you’ve gone down the route of putting the tests in with the binding, you probably also need to do this. If I compare your POM to one of the other test bundles, there’s a lot missing. I also think that the way you have this configured you will end up with the tests being linked into the JAR as you’ve got this in the properties file.

I know you said the skeleton doesn’t work - maybe you should take a look at what’s wrong with this and get it resolved (it should be fixed if it’s broken).

Thanks I will look at zigbee pom.xml

I think that owners of OH are aware of this, because I already posted info about it on this forum

If there’s a confirmed bug then you ought to raise an issue so it’s actually tracked. The forum is great for discussions, but bugs should be raised in the issue tracker.