Automated testing of configuration

Hi Guys,

I’ve been thinking about setting up a proper automated deployment pipeline for my OpenHAB configuration, which is stored in git. I was wondering if anyone had any thoughts on how to run automated tests on the items and rules files before deployment to production?

Initially I’d probably settle just for automated syntax checking as it should be relatively simple to run and doesn’t require me to write a load of test cases. Maybe in the future I’d go further and start writing some test cases for my rules.

Let me know if you have any thoughts.

For JSR223 Jython rules, I’ve been able to write automated regression tests using Python’s unittest framework and an openHAB test fixture that simulates the event bus and data model. The PyCharm Python IDE (including the free community version) can be configured to run a Jython interpreter and it provides a nice UI for interactively running unit tests and developing code. Of course, the tests can also be run from the command line.

This allows me to regression test complex rule logic with a variety of event orderings, simulated binding failures, etc.

That sounds like a good approach, I’ve been considering converting my existing rule set to either Python or Javascript for a while anyway.

Would you be willing to share your test fixture for the OpenHAB specific parts?

I’m willing to share it. I’ll review it to see if it’s ready for general use and place it in a git repository.

1 Like

Sounds great, thanks.

@steve1: how’s the review going? :joy:

Did you upload anything yet? I just started converting my rules to jython and it would be handy to develop testing at the same time.