cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

co♻e unittest framework for CODESYS auf ctrlX

co♻e unittest framework for CODESYS auf ctrlX

therusch
Established Member

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

 

4 REPLIES 4

bostroemc
Occasional Contributor

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:2024-05-08_13h07_39.png2024-05-08_13h08_58.png

To view the device log, double-click the device in the device tree (or click Show status from the context menu):

2024-05-08_13h22_17.png

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

therusch
Established Member

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.

bostroemc
Occasional Contributor

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.

2024-05-10_09h55_27.png

To view the file in the ctrlX CORE's web UI, open the AppData page, then select "File view" in the options (...).

2024-05-10_09h57_13.png

You can then retrieve the file using WebDAV (search this forum for more info) or via the REST API.  For example, in Python:2024-05-10_10h34_01.png

 

therusch
Established Member

This works. 🙂 
I can set the path like this.
Many thanks for your help.

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist