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:
|
The example illustrates that the test 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
:
-
Create the test suite for
myTon
by using the command Create Test Suite. Details: See "Creating a test suite".
Result: The test suite filemyTon.test
and the Excel filemyTon.xlsm
are created in the same folder as the ST-object. -
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 areIN
andPT
.ET
andQ
are the columns for the outputs (= expected results).
This example uses the following test sequences and test data:
Observe that the test sequences 2 up to 9 have not been specified.
Moreover, the predefined cycle time ofT#10ms
has been changed toT#1h
. This will simulate that the 10 cycles will require 10 hours in total. Therefore, the expected result for the outputET
within the 10th test sequence is:TIME#10h
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. -
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". -
As the validation of the unspecified test sequences 2 to 9 is not required: Uncheck 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. -
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.
If error messages such asError 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 Neuron Power Engineer might be started and/or the application might have already been loaded onto the PLC. See "Executing the test" for the necessary steps. -
Check the test execution. Details: See "Checking the test execution".
Due to step 4, the test report contains this piece of additional information:Validate results for unspecified test sequences: No