I’m looking for feedback/advice on implementing automated testing in workflows (app, experience, and edge) for test driven development. I’ve been toying with this a little and here’s what I’ve come up with:
- Break workflows up into microservices…keep them small and easy to test (stateless & functional whenever possible)
- Use virtual buttons and timers to run regular sample payloads through the workflow (basically an assert)
- Use a validate payload node / conditional / switch and or function node to evaluate if the payload is what it should be (the test condition)
- If the test fails, use a function node and a throw statement to raise an exception in the workflow (if you need the workflow to actually “fail”, else just pass a success/failure to the next step)
- Optionally use an MQTT node to push the failure to an event handler workflow which could create / manage events automatically
- Can also use the Workflow Failure trigger to “catch” exceptions raised centrally and push them to an event handler
- Could then use the api to roll back versions for test failure events if so desired, or just notify devs so they can address it.
In this way, I think you could implement unit testing in Losant, for workflows anyways. Experience pages / components would need some kind of workflow specifically to test them…else you’ll be out of Losant and into other testing DSLs (Robot Framework for example). I suspect this approach is also most likely for acceptance testing. For APIs you could simulate this easy enough but much harder for UIs.
Would love to hear feedback and thoughts!