06/28/2022

Automated Test Strategy for ctrlX PLC Applications

Ā 

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 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 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 Assignment
    Variable 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 Case
    Add Action

    Add Action: Close Project
    Add Action: Close Project
    Add Action: Load Project
    Add Action: Load Project
    Add Action: Set Application
    Add Action: Set Application
    Add 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 Progress
  8. Test Report: Here you will see the results of the test. You could save it as an HTML file as well.
    Test Report
2

Latest published/updated articles

Types
How-to
Categories
PLC