This library allows testing of Hubitat scripts locally on your machine (and via Continuous Integration, thus Hubitat CI).
It automatically validates correctness of some script aspects (such as pages/inputs/metadata/preferences/capabilities), and enables user to validate the rest.
It uses GroovyShell to load the scripts, makes objects out of them and lets user test them.
By default, the library will initialize script object, and perform its validation.
These validations can catch errors like these:
- using 'int' instead of 'number' for input type
- removing accidental writes to global state
- detecting unsupported parameters
- Use of unsupported APIs
- Validate command and capabilities method signatures and names
- And many more...
With proper IDE (I'm using IntellijIDEA), you can step through your tests and your script, view variables and have rich debugging experience in general.
Just something obvious, really. If you can run it on your machine, you can also run it in the cloud.
This library, and hubitat_ci_example, for example, have automatic builds set up in Azure Devops (former VSTS). Here's a build script file: azure-pipelines.yml.
- Getting started
- How to test: library usage and common mocking techniques
- Changelog