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.
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.