teaser.png

Automated Test Strategy for ctrlX PLC Applications

DiluMarku
Established Member

 
Overview

This blog will show you how to test your ctrlX PLC Applications using the CODESYS Test Manager.

CODESYS Test Manager

Testing the PLC program code itself. Possibility to create automated tests without any programing-skills and with the use of dialog windows. Effortless integration into PLC Engineering Tool. But needs a special license.

Download the Test Manager and install the package using the package manager of ctrlX PLC Engineering. In order to activate the license for the Test Manager you have to reenable the CodeSys license manager in PLC Engineering or use the online license activator of CodeSys. After that you can open the test manager within PLC Engineering.

Test Manager TabTest Manager Tab

Test Script with dialog windows
  1. Prepare a PLC project you want to test or download the example project, by clicking here. The example project implements a simple statemachine.
  2. Create a new test script for the PLC project and give it a name.
    Create Test ScriptCreate Test Script
  3. Set a base path variable, otherwise the test manager will throw an error if you try to load a project from the disk.
    Add AssignmentAdd AssignmentVariable BasePathVariable BasePath
  4. Add a test case, where the preparations for the actual tests can be done. Add actions to close an open project, load the project you want to test, set the correct application, log into the ctrlX CORE and start the application.
    Add Test CaseAdd Test CaseAdd ActionAdd Action
    Add Action: Close ProjectAdd Action: Close Project
    Add Action: Close Project
    Add Action: Load ProjectAdd Action: Load Project
    Add Action: Load Project
    Add Action: Set ApplicationAdd Action: Set Application
    Add Action: Set Application
    Add Action: Login and StartAdd Action: Login and Start
    Add Action: Login and Start
  5. Actual testing of the PLC application: For each test case, you can use the corresponding actions to test the application.  In this example, each state of the statemachine is tested. The only actions used are CompareVariable and WriteVariable.
    check_init.jpg
    Action: CompareVariable - check initial state
    check_standby.jpg
    Action: CompareVariable - check state after initialization is standby
    start_producing.jpg
    Action: WriteVariable - creating a raising edge
    start_producing2.jpg
    Action: CompareVariable - state changed to producing
    stop_producing.png
    Action: WriteVariable - stop button
    stop_producing2.png
    Action: CompareVariable - check state is stopped
    stop_producing3.png
    Action: CompareVariable - check state is standby
    simulate_error.png
    Action: WriteVariable - simulate error occurrence
    simulate_error2.png
    Action: CompareVariable - check error state
    clear_error.png
    Action: WriteVariable - clear the error
    clear_error2.png
    Action: CompareVariable - check state change to initial
    clear_error3.png
    Action: CompareVariable - state is again standby
  6. Cleanup: Reset the application, logout and close the project
    cleanup.png
    Action: ResetApplication - reset application
    cleanup2.png
    Action: Logout - log out of CORE
    cleanup3.png
    Action: CloseProject - close the project
  7. Test execution: Save the test script and press on the green play button to execute the full test script. In the popup window, you can enter your name if you want to, just make sure the option "Create verbose report" is marked to get the full report and press start. While the test is running you can follow each step in the popup window and see the test progress.
    Test ProgressTest Progress
  8. Test Report: Here you will see the results of the test. You could save it as an HTML file as well.
    Test ReportTest Report
Must Read
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