Example 4: Test case for myTon with simulated cycle time and unspecified test sequences

This example illustrates how to create and execute a test for the function block myTon provided by the following ST-code:

FUNCTION_BLOCK myTon
VAR_INPUT
IN : BOOL;
PT : TIME;
END_VAR
VAR_OUTPUT
Q : BOOL;
ET : TIME;
END_VAR
 
VAR
var1 : TON;
END_VAR
var1(IN := IN, PT := PT, Q=>Q, ET =>ET);
END_FUNCTION_BLOCK

The example illustrates that the t est sequences for myTon are executed as fast as possible while a predefined cycle time is simulating that the predefined time of 1 hour passes per cycle (= test sequence). The test case even contains some unspecified test sequences.
See "TON block" about the functionality of the TON block.

How to test the above function block myTon:

  1. Create the test suite for myTon by using the command Create Test Suite. Details: See "Creating a test suite".
    Result: The test suite file myTon.test and the Excel file myTon.xlsm are created in the same folder as the ST-object.

  2. Open the Excel file, enter the test data in the existing worksheet test myTon and save the modified Excel file.
    The worksheet already contains the columns for the variables delivering the input data. Here these columns are IN and PT. ET and Q are the columns for the outputs (= expected results).
    This example uses the following test sequences and test data:
    images/download/attachments/453673802/TF_TestsuiteExampleMyTon-version-1-modificationdate-1605264120037-api-v2.png
    Observe that the test sequences 2 up to 9 have not been specified.
    Moreover, the predefined cycle time of T#10ms has been changed to T#1h. This will simulate that the 10 cycles will require 10 hours in total. Therefore, the expected result for the output ET within the 10th test sequence is: TIME#10h
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg The Excel file also contains other worksheets that are not used in this example. See "Structure of the Excel test suite, modifying the worksheets" for information on these worksheets.

  3. Transfer all test data from the Excel file to the test suite file myTon.test by importing the Excel file. Details: See "Create the test suite based on the Excel file for the test execution".

  4. As the validation of the unspecified test sequences 2 to 9 is not required: U ncheck the setting Validate results for unspecified test sequences within the properties of the project (context menu of the project, command Properties and Test framework ).
    See details under "Structure of the Excel test suite, modifying the worksheets", if you need information on the unspecified test sequences .

  5. Have the tests executed, e.g. run a SiL-test. Details: See "Executing the test".
    Result of the test execution: The console displays the progress and the result of the test execution. PASS is displayed as the result of the test execution. The test execution takes only some seconds although it is simulated that the test execution took 10 hours.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If error messages such as Error at output "ET" in test sequence 2. Expected: TIME#1h but was: TIME#2h are displayed, the validation of the unspecified test sequences has not been unchecked (see step 4).
    If other error messages are displayed, a different version of logi.CAD 3 might be started and/or the application might have already been loaded onto the PLC. See "Executing the test" for the necessary steps.

  6. Check the test execution. Details: See "Checking the test execution".
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Due to step 4, the test report contains this piece of additional information: Validate results for unspecified test sequences: No