Dear TwinCAT/PLC developers,
I’m very happy to announce the release of the TcUnit-Runner, an open-source tool for integration of TwinCAT unit tests into a CI/CD toolchain automation server such as Jenkins. When TcUnit, the TwinCAT unit testing framework, was released back in December of 2018 I would never have imagined how widespread it would get. Since then, I’ve received e-mails from PLC developers every week with questions, improvement suggestions or just gratitude for this open-source software. The TcUnit framework has found its way into the full range of projects ranging from small machines to multi-billion € projects. With this response, I would say that there definitely is a need for unit testing in the world of automation. The adoption of TcUnit into TwinCAT projects across the globe has motivated the further development of TcUnit. One limitation of the TcUnit framework was that it was only possible to run the unit tests locally on your development machine (or PLC), and thus needed to be run manually every time a change in the software was made. Modern software practices advocate that software development should adhere to the practices of continuous integration/continuous delivery (CI/CD), so that tests would be run automatically when committing changes to version control. Thus, TcUnit-Runner was developed.
TcUnit-Runner is an open-source software that makes it possible to integrate TwinCAT unit tests in a CI/CD software such as Jenkins.
With Jenkins and a version control system (such as Git or SVN), it’s possible to automatically run all unit tests in a TwinCAT project automatically if a TwinCAT project is changed in the version control system. All test results are automatically generated and reported in standard xUnit/JUnit XML format which Jenkins natively supports.
The software is released as version 0.9 and hopefully this software and the documentation will receive feedback for a 1.0 release in the coming weeks. With the release of this software my hope is that it facilitates the adoption of modern software development practices among PLC developers. As always, all software is open-source and MIT-licensed, which means it can be used freely for non-commercial and commercial re-distribution, whether in source or binary form. I hope that TwinCAT developers will make use of this software and provide feedback so that it can constantly evolve. As of today, a dozen people have contributed to the project.
Want to get started?
Want to access the source code and/or contribute to the project?
Please visit the GitHub project page.
If you are completely new to unit testing in general and unit testing in TwinCAT/PLCs in particular I recommend reading the: