FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
3 weeks ago
Hello,
I am trying to write PLC unit tests with the codesys unittest framework co♻e.
The tests run fine and complete, but there neither is a test result output in the message list, nor a result file.
ctrlX is not listed as compatible here: https://forge.codesys.com/lib/counit/apireference/API%20Reference/
Did anyone successfully run co♻e unittests on ctrlX, or is there an alternative testing framework?
Thank you and best regards
Solved! Go to Solution.
3 weeks ago - last edited 3 weeks ago
The unit test results are available in the device log by choosing "coUnit" in the dropdown. Following the tutorial given here, I see the following results before and after implementing the body of FB_Sum:
To view the device log, double-click the device in the device tree (or click Show status from the context menu):
It's also possible to retrieve the results using function block FB_TestResults from the coUnit library. See method GetTestSuiteResults.
Test suite: ctrlX PLC Engineering 2.4.x; co♻e framework 1.2.0.0
3 weeks ago
Hi,
thank you for your answer. There they really are. 👍
Do you have an idea, how I can get these logs with scripting? Maybe redirect them to the standard output or get the device log via web API somehow?
Or is the testresults xml-file written in your case? In my case it is not. Not on my computer and not on the PLC (can't even set a linux style path).
I try to include the Test Run into a CI/CD pipeline, so I need the results accessible without UI.
Thank you so much for your help.
3 weeks ago
The test results are exported automatically to location xUnitFilePath, defined in the libary parameters. Setting xUnitFilePath='/var/snap/rexroth-solutions/common/solutions/activeConfiguration/coUnit_xunit_testresults.xml' will push the results to the base folder of the active configuration.
To view the file in the ctrlX CORE's web UI, open the AppData page, then select "File view" in the options (...).
You can then retrieve the file using WebDAV (search this forum for more info) or via the REST API. For example, in Python:
2 weeks ago
This works. 🙂
I can set the path like this.
Many thanks for your help.