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?
Go to the user manual, which includes an introduction, a quick start and a full example.
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:
- Core concepts of unit testing
- Introduction user guide to TcUnit (the TwinCAT unit testing framework)
- TcUnit website
Really appreciate the work put into this! Will be trying to integrate this into an Azure CI/CD pipeline very soon
Thanks! If you find any bugs/improvement suggestions, please let me know!
Hi! I am very excited about this new tool, I already created something similar myself with help of your static code analysis example. However, when I am trying to use TcUnitRunner with Jenkins, it seems to always hang after successfully loading the VS DTE. Any ideas why?
Hi Ivana! Thanks for the feedback! Are you running the latest version (0.9.2.0)? If so and it still doesn’t work, please create an issue here so that I can look into it!
This seems like a great tool – thank you for creating it!
I would like to start using TcUnit, but with GitHub Actions using a self-hosted runner instead of with Jenkins. Are there any specific challenges or recommendations for using this alternative solution?
It’s relatively straightforward, according to GitHub themselves at least. 🙂