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:

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

Info

information on the author (incl. date), reviewer (incl. date), referenced documents

Change History

history of the changes

Excluded Req.

requirements for which a dynamic test is not possible

Defaults

defaults for stimuli – only possible, if the variable is not specified in the following worksheets (= test cases)

test testCase Name

defaults for the first test case with the default name test testCase Name
A test case consists of several test sequences (you may insert as many as you need). The test sequence specifies the input data and the expected outcome for the POU under test. Moreover, you are able to enter internal comments, requirements and descriptions per test sequence.

Create only up to 5.000 test sequences per Excel file. This limitation is valid as sum all test cases.
In case of more test sequences, the optimal usage of the test framework cannot be guaranteed but the test execution might behave sluggishly.

Enter up to 55.000 data per test case. Mind that the data is calculated as follows:

(input data per test case + expected results per test case) * test sequences per test case

If you enter more data within a test case, the following message appears when the test case is executed: Test case contains too many test sequences and/or inputs/outputs

Workaround, if there are unspecified test sequences within the test case: Uncheck the setting Validate results for unspecified test sequences before you start the test.

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.
images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Here are the variables that are able to deliver input data for the test run:

Complete the data as follows:

  1. 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 column Stimuli.

  2. If required: Enter any text within the column Comment (Default).

  3. 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.
    logi.CAD 3 has entered the test mode depending on the usage of the variable. logi.CAD 3 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 worksheet Defaults is used.

    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.

    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
    See "Beispiel 3: Testfall für Addition mit lokaler Variable, unterschiedlichem Testmodus und Initialisierungswert" for an example how the test mode for a local variable affects the test result.

  4. If required: Enter any text within the column Comment (Test Mode).

Initial value of a local variable specified within the application

When executing a test, an initial value for a local variable is considered – as long as you specified this initial value within the worksheet Defaults of the test suite. However, if you have specified an initial value within the application (e.g. by the ST statement iDelta : INT := 2;), this initial value is not considered when executing the test – even if the initial value for the local variable has been removed from the worksheet Defaults of the test suite.

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.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg logi.cals 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:

  1. 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").
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg 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, logi.CAD 3 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.

  2. For each new test sequence, insert a number within the column Time. The number 0 is already entered for the first test sequence, enter the number 1 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 sequences 0, 1, 2, 5, 6 (because of the skipped numbers 3 and 4).
    Mind the following, if there are unspecified test sequences:

    • When an unspecified test sequence is validated, logi.CAD 3 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.

  3. 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
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg 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 worksheet Defaults.

    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Here are the variables that are able to deliver input data for the test run:

    name of the output or return value
    (= columns with Tolerance and Shift in the header)

    expected result (for the output or return value)
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If you are using Excel formulas in order to calculate the expected results for REAL or LREAL 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 : logi.CAD 3 calculates the REAL and LREAL values with the appropriately significant digits (details: see information on the REAL and LREAL 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.

  4. 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 for Tolerance is interpreted as fluctuation range.
      Tolerance = 0 is the default for no deviation.
      Example: In the case of the expected result 10 with Tolerance = 2.0, the actual value for the executed test may be 8 up to 12.

    • Shift specifies the allowed deviations for the time (as integer number). If you enter a value for Shift, 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 for Shift = 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 sequence 0) or
      6 (= the expected result of the current test sequence 1)

      1

      6

      5 (= the expected result of the test sequence 0) or
      6 (= the expected result of the current test sequence 1) or
      7 (= the expected result of the test sequence 2)

      2

      7

      6 (= the expected result of the test sequence 1) or
      7 (= the expected result of the current test sequence 2)

  5. 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 line Init 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.
images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg 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.