Skip to main content

Basics

CODESYS Test Manager is a testing framework for software written in CODESYS Development System. You can use the testing framework to execute automated tests to verify the correctness of software at different test levels. The test is ranked according to the process model of software development, in which each stage of software development is subjected to a test. When you have decided at which level the test is to be performed, you can derive how your test should be implemented.

System test

With a system test, you verify that a system works correctly and permanently without errors. In this case, the testee is the entire system, for example:

  • an application

  • a library

  • a communication connection

  • a runtime system

  • a code generator

The system test checks the system completely against the functional and non-functional requirements. The test environment simulates the later production environment. Therefore, the test environment should be as realistic as possible.

You perform a system test by implementing a test script. The test script performs a test run with test cases and test actions. The corresponding test project contains a compilable application with the system settings of the test system.

Unit test

With a unit test, you verify that a single, definable part of the IEC code works correctly. In this case, the testee is only this part, for example:

  • a program

  • a function block

  • a method

  • a property

The unit test shows that the code is technically executable and delivers correct functional results, including partial results. Other names for the unit test are component test and module test. The software developers often perform the unit tests themselves – for example in Test Driven Development.

You perform a unit test by developing a test project. The test project contains the testee and additional code which tests the testee. You implement this test code either formally as a test table or programmatically as a test POU or multitest POU.

In addition, you implement a suitable test script with the IEC Unit Test test element. The test script can also contain test cases with test actions.

Before the test run, you load the test project and configure it for the test run. This includes the communication settings, for example. During the test run, the IEC Unit Test test element searches the loaded test project for test tables, test POUs, and multitest POUs. The test element creates the test application from the test code found and then executes the individual test cases.

Procedure

For both test types, you implement an executable test script and a test project. During the test run, the Test Manager executes the test cases on the test system and evaluates them. A test report is created automatically from the result.

Procedure. Creating an automatic test
  1. Create a test project.

  2. If a test repository does not exist yet, then create a test repository.

  3. In the Test Manager view, create a test script and program the test script with test elements.

    The test script generally works with the contents of the test project. For example, the DeleteObjects test driver action needs an object from the test project.

Procedure. Executing an automatic test
  1. In the Test Manager view, on the Test Scripts tab, right-click the test script and select Execute Script.

    The Execute Test dialog will open.

  2. Click Start.

    After the test run, the test report will open.

  3. In the test report, click Save as HTML.

    1. If no report directory is defined, then a dialog will open.

      Select the target directory there.

    The test report is saved as an HTML file. You can open the HTML file in a browser.

  4. In the test report, check which test cases and test actions have failed.

    The test report shows failed test cases and test actions in red with the Failed status. The error message is displayed below a failed test action. Start with the first failed test action because an error can cause subsequent errors.

  5. Fix the errors in the testee.

  6. Run the test script again.

Tip

A test case can also fail if the test script or the test code contains an error. Therefore, if test cases fail, then also check the test script, the test tables, and the test POUs.

Tip

By means of command line commands, you can call the Test Manager outside of the development environment. In this way, you can integrate the Test Manager permanently into a system without starting the development environment, for example for Continuous Integration.

For more information, see the following: Test execution via the command line and --noUI support