Automated Test Strategy for ctrlX PLC Applications

Established Member


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.
    Action: CompareVariable - check initial state
    Action: CompareVariable - check state after initialization is standby
    Action: WriteVariable - creating a raising edge
    Action: CompareVariable - state changed to producing
    Action: WriteVariable - stop button
    Action: CompareVariable - check state is stopped
    Action: CompareVariable - check state is standby
    Action: WriteVariable - simulate error occurrence
    Action: CompareVariable - check error state
    Action: WriteVariable - clear the error
    Action: CompareVariable - check state change to initial
    Action: CompareVariable - state is again standby
  6. Cleanup: Reset the application, logout and close the project
    Action: ResetApplication - reset application
    Action: Logout - log out of CORE
    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