Unit- /Integration-Testing Ignition modules?

Hi all,

so after getting my IoTDB Historian sort of working ... I'd love to add some automated tests.

I could possibly mock the subsystems, but mocking a system you don't understand doesn't really test things ... I would be building the mocks to reflect my interpretation of reality and not what's really happening. But I guess I'm not the only one facing this problem.

So ... is there any form of framework that helps unit- or integration-testing Ignition modules?

Chris

The dividing line would be whether what you're testing requires a running gateway or not.

If you're testing methods that don't rely on a running gateway (e.g. you could supply mocked data to a function and test that the output is what you expect), then unit testing is no different from any other application. Internally at IA we're using JUnit 5, but any Java unit testing framework would do as well.

If you're testing methods that rely on a gateway, you need to decide if using a framework with a unit test will do what you want or if you're really looking at an integration test. For the former, internally we use Mockito. For ideas on the latter, I'd recommend watching Cody Mallonee's excellent talk on the subject and the associated github repo. While those last two things are geared towards Perspective projects, I think they're a good primer to integration testing Ignition.

1 Like