Domotest – A Lua rock to aid testing Domoticz event scripts
Posted: Sunday 09 October 2016 20:18
I made a little Lua library/script to help with unit testing Domoticz event scripts. It hides a lot of the boilerplate required to get standard Domoticz-compatible Lua scripts loaded into a test environment (such as Busted).
Useful if you don't have actual devices and want to get a script up and running, or if you want/need the security of having your event scripts covered by tests.
Installation is simple with luarocks:
There's a bit more info on the blog post here: http://stevewilford.co.uk/2016/10/domotest-launch/
And even more info, and examples, in the git repo: https://github.com/NxSoftware/domotest
Hope this is of use to someone...
Useful if you don't have actual devices and want to get a script up and running, or if you want/need the security of having your event scripts covered by tests.
Code: Select all
require 'domotest'
require 'busted.runner'()
describe('Bathroom motion sensor', function()
describe('detects motion at night', function()
it('turns on the light', function()
commandArray = domotest('script_device_bathroommotion.lua', {
devicechanged = { ['Bathroom Motion'] = 'On' },
timeofday = { ['Nighttime'] = true }
})
assert.are.same({
['Bathroom Lights'] = 'On'
}, commandArray)
end)
end)
end)
Code: Select all
luarocks install domotest

There's a bit more info on the blog post here: http://stevewilford.co.uk/2016/10/domotest-launch/
And even more info, and examples, in the git repo: https://github.com/NxSoftware/domotest
Hope this is of use to someone...