Structure of the Excel test suite, modifying the worksheets
You need a test suite in order to execute →unit tests. The test suite in Excel format makes it simpler to modify the test suite.
This article informs about:
In this article: |
---|
See "Creating a test suite" and/or "Modifying the Excel test suite, creating the test suite required for test execution" for information on how to create the Excel test suite and on how to create the test suite actually required for the test execution.
List of existing worksheets
The Excel file already contains these predefined worksheets:
Title of worksheet |
Purpose |
|||
---|---|---|---|---|
|
information on the author (incl. date), reviewer (incl. date), referenced documents |
|||
|
history of the changes |
|||
|
requirements for which a dynamic test is not possible |
|||
|
defaults for stimuli – only possible, if the variable is not specified in the following worksheets (= test cases) |
|||
|
defaults for the first test case with the default name
|
Modifying the worksheets
If a test suite contains special characters (such as umlauts, e.g. ä, ö, ü), these special characters are ignored when the test is running. Hence, best practice is to use only ASCII characters when creating/modifying the test suite. |
Modifying the worksheets Info, Change History and Excluded Req.
Complete the data in the existing worksheets Info
, Change History
and Excluded Req.
Modifying the worksheet Defaults
Complete the data in the existing worksheet Defaults
, if a variable delivering input data is not specified in the test cases.
Here are the variables that are able to deliver input data for the test run:
-
local →variables (=
VAR
) -
→input variables (=
VAR_INPUT
) -
→in-out variables (=
VAR_IN_OUT
) -
→external variables (=
VAR_EXTERNAL
)
Complete the data as follows:
-
Enter a value in the column
Default Value
within the line for the variable (e.g.IN4
).
The name of the variable is already entered within the columnStimuli
. -
If required: Enter any text within the column
Comment (Default)
. -
Check the test mode already entered in the column
Test Mode
, if the variable is a local variable, an in-out variable or an external variable (the test mode is not relevant for an input variable). If required, change this test mode.
Neuron Power Engineer has entered the test mode depending on the usage of the variable. Neuron Power Engineer supports the following test modes:Test mode
Automatically entered, if...
Meaning
useTestValue
... the variable is only read.
The test uses the value that is specified for the variable within the test case.
If the variable is not specified within any test case, the value from the worksheetDefaults
is used.See "Example 3: Test case for addition with local variable, different test mode and stimuli" for an example of how this test mode for a local variable affects the test result.
useLastValue
... the variable is written to.
The test uses the last value of the previous cycle of the test run. In the case of the first cycle, the →initial value of the variable is used.
See "Example 3: Test case for addition with local variable, different test mode and stimuli for an example of how this test mode for a local variable affects the test result.
useImplValue
–
(You have to enter this test mode yourself.)The test uses the initial value specified within the application – in case of the following actions:
You have deleted the predefined value in the column
Default Value
within the line for the variable.The variable is not specified within any test case.
See "Example 5: Test case for addition with initial value of a local variable" for an example of how this test mode for a local variable affects the test result.
If you enter other texts within the column
Test Mode
or if you delete one of the texts, it will not be possible to run the test -
If required: Enter any text within the column
Comment (Test Mode)
.
Modifying the defaults for the test case
Complete the data in the predefined worksheet that corresponds to the test case, e.g. within the worksheet test testCase Name
.
Neuron recommends to rename the worksheet to a significant name by using the Excel features so that you are able to uniquely assign the test case. Example: Testing Motor Ax3491
Example for worksheets with test data are listed under "Modifying the Excel test suite, creating the test suite required for test execution".
Specify the test sequences for the test case:
-
If required: In the column
Time
, change the default for the simulated cycle time (the →duration literal) as 2nd line in the header.
By default, the test case uses the simulated cycle time defined within the properties of the project (see under "Preparing an existing project for tests").
Each test per test sequence is executed as fast as possible so that the 2nd cycle (= 2nd test sequence) is started immediately after the 1st cycle (= 1st test sequence), the 3rd cycle (= 3rd test sequence) immediately after the 2nd cycle (= 2nd test sequence) etc. Due to the simulated cycle time, Neuron Power Engineer simulates that the specified time has elapsed per cycle before the next test sequences is started. See "Example 4: Test case for myTon with simulated cycle time and unspecified test sequences" for an example about the impact of the simulated cycle time. -
For each new test sequence, insert a number within the column
Time
. The number0
is already entered for the first test sequence, enter the number1
for the second test sequence etc.
If you want to have unspecified test sequences within the test case, enter a higher number for the next test sequence. Example: Two test sequences are unspecified in case of test sequences0, 1, 2, 5, 6
(because of the skipped numbers3
and4
).
Mind the following, if there are unspecified test sequences:-
When an unspecified test sequence is validated, Neuron Power Engineer is using the results of the previously specified test sequence.
-
By default, the results for the unspecified test sequences are validated. But if you do not need this validation, uncheck the setting Validate results for unspecified test sequences before you start the test (see also under "Example 4: Test case for myTon with simulated cycle time and unspecified test sequences"). No matter, if this setting is checked or unchecked, the unspecified test sequences are always executed when the test is executed.
-
The test report of an executed test contains an appropriate additional information whether unspecified test sequences have been validated or not. You find the additional information within the section
Test Details
for the appropriate site.
-
-
For each test sequence, enter the following data in the appropriate columns. See "Example 1: Excel file with test case for ADD" for an illustration.
Column
Data for this column
name of the variable delivering input data (e.g.
IN1
)input data for this variable
Delete the columns for the variables that should not be specified within the test case – but you must specify defaults for such variables within the worksheetDefaults
.Here are the variables that are able to deliver input data for the test run:
local →variables (=
VAR
)→input variables (=
VAR_INPUT
)→in-out variables (=
VAR_IN_OUT
)→external variables (=
VAR_EXTERNAL
)name of the output or return value
(= columns withTolerance
andShift
in the header)expected result (for the output or return value)
If you are using Excel formulas in order to calculate the expected results forREAL
orLREAL
values (e.g. the formula to calculate a sine value), round these results to the significant digits within the Excel file (e.g. use the formula to round the value). Reason: Neuron Power Engineer calculates theREAL
andLREAL
values with the appropriately significant digits (details: see information on theREAL
andLREAL
data type).Comments
an internal comment that will not be included within the test report
Requirements
requirements for the dynamized test
Description
description of the test sequence
Restrictions
See "Restrictions when using the test frameworks" for restrictions when executing a test suite.
-
If required: In the columns for output or return value, enter the allowed deviations in the header.
-
Tolerance
specifies the allowed deviations for the amplitude (as positive floating-point number). The specified value forTolerance
is interpreted as fluctuation range.Tolerance = 0
is the default for no deviation.
Example: In the case of the expected result10
withTolerance = 2.0
, the actual value for the executed test may be8
up to12
. -
Shift
specifies the allowed deviations for the time (as integer number). If you enter a value forShift
, the expected result of the current test sequence as well as the expected results of the appropriate previous/following test sequences are accepted as the actual value.Shift = 0
is the default for no deviation.
Example forShift = 1
: The expected result of the current test sequence as well as the expected result of 1 previous/following test sequence are accepted as the actual value.Test sequence
expected result
The actual value may be one of these value:
0
5
5
(= the expected result of the test sequence0
) or6
(= the expected result of the current test sequence1
)1
6
5
(= the expected result of the test sequence0
) or6
(= the expected result of the current test sequence1
) or7
(= the expected result of the test sequence2
)2
7
6
(= the expected result of the test sequence1
) or7
(= the expected result of the current test sequence2
)
-
-
If required for a program or a function block (not supported for a function): Define initial values for outputs. This makes it possible e.g. to test the overflow for a counter block.
-
First insert the line
Init
within the Excel file (by using the Excel command Insert Cells...). The line must be inserted in front of the first line for the test sequences. See "Example 2: Excel file with test case incl. initial values for blocks outputs" for an illustration. -
Then enter the initial values in the columns for the function block outputs for which you need an initial value.
-
Finally enter the character
/
in the columns delivering input data and all other columns of the outputs. These inputs are required so that the lineInit
will be processed correctly.
-
Creating a new worksheet for a new test case
If you need more than one test case for the POU, insert additional worksheets after the last worksheet.
Best practice is to copy the worksheet with the first test case and insert the new test case behind this first test case. Then modify the new test case (as just described): Enter a meaningful name, specify the test sequences, the data within the columns incl. possible deviations.