Create a Sequence Unit Test

This section describes how to create a sequence unit test (file extension .seqtst), a type of unit test that executes a sequence of test steps in a specified order. Each test step executes a business service or Natural unit test and, optionally, copies data between steps, applies field overrides, defines validation overrides. and/or applies method overrides (business service unit tests only). These overrides do not physically change the existing unit test files; the values are only changed in memory prior to execution of the files.

For example, a sequence test can have the following two steps:

  1. Invoke a unit test for a Construct-generated object-maintenance subprogram and attempt to retrieve (GET) a data record.

  2. Re-invoke the same test, but apply a field override that attempts to update the record. In addition, copy all data from Step 1 and pre-configure each input field.

There are several methods you can use to create a sequence unit test, depending on your requirements. These methods include:

  • Create one generic business service or Natural unit test and then create a sequence unit test containing several test steps that reference the same generic unit test, but use a different field override.

    For example, you can create a generic Natural unit test called WAREHOUSE.nattst and then create a unit test that reference a sequence of unit tests to override the value of WAREHOUSE.#FUNCTION, such as WAREHOUSE_GET.nattst, WAREHOUSE_NEXT.nattst, etc.

  • Create several business service and/or Natural unit tests that reference the same subprogram/PDA and then create a sequence unit test that references each unit test in a specified sequence.

    For example, you can create a unit test for each warehouse function, such as WAREHOUSE_GET.nattst, WAREHOUSE_NEXT.nattst, etc., and then create a unit test that invokes these tests in a specified sequence.

  • Create several business service and/or Natural unit tests that reference different subprograms/PDAs and then create a sequence unit test that references each unit test in a specified sequence and copies data from one test to the next.

  • Create a sequence unit test and one or more unit tests to use for the test.

The following topics are covered:


Create the Unit Test

This section describes how to use the wizard to create a sequence unit test.

Start of instruction setTo create a sequence unit test

  1. Open the context menu for one of the following items in the Project Explorer view:

    • Project folder

    • Testing-Suites folder or subfolder

    • One or more business service and/or Natural unit test files (using standard selection techniques). The tests can reference the same subprogram/PDA or different subprograms/PDAs. The wizard will create one test step in the generated sequence unit test for each unit test selected in the Project Explorer view.

  2. Select Testing > Create Sequence Unit Test.

    The Define Sequence Unit Test Details panel is displayed. For example:

    graphics/define-sequence-unit-test-details.png

  3. Type the name of the sequence unit test in Test name.

    Optionally, you can:

    Task Procedure
    Change the name of the project in which to create the sequence unit test. Type the name of the Natural project in Project or select Browse to display a window listing the existing projects for selection.

    Note:
    The project must currently exist.

    Provide the name(s) of a subfolder(s) in which to save the sequence unit test. If the folder does not currently exist, it will be generated for you. Type the name of the folder in Parent suite or select Browse to display a window listing the available folders for selection.

    By default, the unit test is stored in the Testing-Suites folder in the current project. If you specify a suite folder name, it becomes a subfolder in the Testing-Suites folder and the unit test will be stored in that folder.

  4. Select Finish.

    The sequence unit test file is generated into the Testing-Suites folder (or subfolder) and listed in the Project Explorer view.

    The .seqtst file is also displayed in the editor view. For example:

    graphics/seqtst-file-in-editor-add-step.png

    If one unit test file was selected in the Project Explorer view, a default test step is created for that file. For example:

    graphics/seqtst-file-in-editor-one-nat-unit-test.png

    If several unit test files were selected in the Project Explorer view, one test step is created for each test. For example:

    graphics/seqtst-file-in-editor-several-nat-unit-tests.png

Use the Sequence Unit Test Editor

This section describes how to use the sequence unit test editor. The following topics are covered:

Notes:

  1. For information about the Connections tab, see Define Connections.
  2. For general information about using the test editors, see Features of the Test Editors

Add Test Steps

This section describes how to add test steps to execute business service and/or Natural unit tests in a specified order. Each test step executes one existing unit test and, optionally, copies data between steps, applies field overrides, and/or defines validation overrides. In the following example, the sequence unit test is generated from the context menu for a project and no steps are created. For example:

graphics/seqtst-file-in-editor-add-step.png

Note:
To resize the editor sections, select the sash and move it left or right.

Start of instruction setTo add test steps

  1. Select Add.

    The Test Step Details section is displayed. For example:

    graphics/seqtst-file-in-editor-add-step-details.png

  2. Select Browse for Unit test file.

    The Select Unit Test window is displayed. Select the unit test file and OK. The unit test details are displayed in the Test Steps section and the selected unit test file is displayed in Unit test file. For example:

    graphics/seqtst-file-in-editor-add-step-details-2.png

    Or:
    Select New for Unit test file.

    The Select Unit Test Type panel is displayed. For example:

    graphics/seqtst-file-in-editor-add-new-unit-test.png

    Select one of the following options:

    Note:
    When accessing these panels from the sequence unit test editor, the project name defaults to the name of the project containing the sequence unit test and is read-only. The unit test file specified for each test step must contain a relative path to the Testing-Suites folder in the project containing the sequence unit test.

    After defining the unit test and selecting Finish, the unit test details are displayed in the Test Steps section and the newly created unit test file is displayed in Unit test file.

  3. Select Add.

    The second test step is displayed in Test Steps and the Copy data section is enabled. For example:

    graphics/seqtst-file-in-editor-add-step-details-3.png

  4. Select or create the unit test for the second test step.

    Repeat steps 1 and 2 until all test steps have been added. Optionally, you can use this editor to:

    Task Procedure
    Provide a description of this test step. Type a description of the test step in Description (maximum of 250 characters). The first 60 characters are displayed as the tool tip for the test step in Test Steps.
    Copy data from a previous step. See Copy Data from a Previous Step.
    Delete a test step. Select the test step in Test Steps and select Remove or open the context menu for the test step and select Delete.
    Reorder the test steps. Select the test step in Test Steps and select Up or Down.
    Provide a name for the test step. Type the step name in Name.
    Define an input override for a field used in a test step. See Add an Input Override.
    Define a validation override for a field used in a test step. See Add a Validation Override.
    Define a method override for a method used in a test step (business service unit tests only). See Add a Method Override.
  5. Save the settings.

Copy Data from a Previous Step

This section describes how to copy data from a previous test step. When the generated sequence test is run, the test step will attempt to copy the data from the specified test step. If the test steps share the same Natural unit test file, the entire data structure from the previous test step is copied. If the test steps use different Natural unit test files, each field is copied by name and the level 1 name (if present) is compared to the field name.

Warning:
All values are copied, even when the Natural formats are different. This may result in conversion errors (for example, when alpha values are placed in numeric fields).

Start of instruction setTo copy data from a previous test step

  1. Select the test step to which you want to copy the data.

  2. Select Copy data from a previous step.

  3. Select the test step from which you want to copy the data in Step name.

    You can select any previous test step in the list. Only previous test steps are listed, as data cannot be copied from a test step that has not been run.

    Note:
    When defining input or validation overrides, you can also select the field from which to copy the data.

Add an Input Override

This section describes how to add an input override for a field. This value will override any input value defined for an input field with the same name in the original unit test file. For example, if the original unit test file has an input field and value of FUNCTION=GET and you add an override to a test step that sets FUNCTION=UPDATE, then FUNCTION=UPDATE will be used.

Start of instruction setTo add an input override

  1. Open the context menu for the test step in Test Steps.

  2. Select New > Input Override.

    The field details are displayed in Test Step Details. For example:

    graphics/seqtst-file-in-editor-add-input-override.png

  3. Type the override value in Value.

    The input override is displayed in Test Steps. For example:

    graphics/seqtst-file-in-editor-add-input-override-2.png

    In this example, an override value for the CUSTOMER-NUMBER field has been added.

    Notes:

    1. For information about the input parameters, see Configure Input Parameters.
    2. You can copy the field data from a previous step. For information, see Copy Data from a Previous Step.
    3. To remove an input override, either select the override in Test Steps and select Remove or open the context menu for the override and select Delete.

Add a Validation Override

This section describes how to add an override value for a field validation. This value will override any validation defined for an input field with the same name in the original unit test file. For example, if the original unit test file has a field validation of #MSG <> ERROR and you add a validation override of #MSG <> WARNING, then both validations will be used (i.e., the wizard will ensure that the message is not equal to both ERROR and WARNING).

Start of instruction setTo add a validation override

  1. Open the context menu for the test step in Test Steps.

  2. Select New > Validation Override.

    The validation details are displayed in Test Step Details. For example:

    graphics/seqtst-file-in-editor-add-validation-override.png

  3. Select the field name in Field name.

  4. Select the override value in Validator.

    The validation override is displayed in Test Steps. For example:

    graphics/seqtst-file-in-editor-add-validation-override-2.png

    In this example, an override validation for the CUSTOMER-TIMESTAMP field has been added.

    Notes:

    1. For information about the validation parameters, see Define Validations.
    2. You can copy the validation data from a previous step. For information, see Copy Data from a Previous Step.
    3. To remove a validation override, either select the override and select Remove or open the context menu for the override and select Delete.

Add a Method Override

This section describes how to add a method override value for a business service unit test. This value will override the method name in the original business service unit test. For example, if the original unit test has a method value of "BROWSE" and you add a method override value "EXISTS" to a test step, then the sequence unit test will execute the "EXISTS" method.

Start of instruction setTo add a method override

  1. Open the context menu for the test step in Test Steps.

  2. Select New > Method Override.

    The method details are displayed in Test Step Details. For example:

    graphics/seqtst-file-in-editor-add-method-override.png

  3. Type the override value in Method.

    The method override is displayed in Test Steps. For example:

    graphics/seqtst-file-in-editor-add-method-override-2.png

    In this example, an override value of METHOD=EXISTS has been added.

    Notes:

    1. For information about business service methods, see NaturalONE's Business Services documentation.
    2. To remove a method override, either select the override in Test Steps and select Remove or open the context menu for the override and select Delete.

Use the Dependencies View

When a generated module is open in the editor, the Dependencies view displays dependencies between a sequence unit test and the unit tests executed for each test step. This section describes the nodes contributed to the view for these resources. The following topics are covered:

Notes:

  1. Select graphics/sort-alphabetically-icon.png to sort the resources alphabetically.
  2. Select graphics/dependencies-view-export-icon.png to export a textual representation of the visible nodes in the view to a file.
  3. When a supporting resource cannot be found locally using the project steplib chain and project references, "<Unknown>" is displayed with the name of the resource. If the unknown module(s) is not shipped with the Construct runtime project, either manually download it from the server or create it locally. If the module(s) is shipped with the Construct runtime project, add the project. For information, see NaturalONE's Code Generation documentation.
  4. For more information about the Dependencies view, see the description of the source editor in Using NaturalONE.

Sequence Unit Test Resources

When a sequence unit test is open in the editor view, the root node displays the name of the sequence unit test. In caller mode (graphics/caller-mode-icon.png), no child nodes are displayed because no other Dependencies view objects depend on this sequence unit test file. For example:

graphics/dependencies-view-sequence-unit-test-caller-mode.png

In callee mode (graphics/callee-mode-icon.png), the child nodes display one business service or Natural unit test for each test step in the sequence unit test. For example:

graphics/dependencies-view-sequence-unit-test-callee-mode.png

Business Service Unit Test Resources

When a business service unit test is open in the editor view, the root node displays the name of the unit test. In caller mode (graphics/caller-mode-icon.png), one child node is displayed for each sequence unit test that includes this unit test in one of its test steps. For example:

graphics/dependencies-view-bs-unit-test-caller-mode-seq-unit-test.png

In callee mode (graphics/callee-mode-icon.png), the child node displays the name of the business service that the unit test executes, along with the names of the supporting Natural resources and the names of the libraries and projects in which they are located. For example:

graphics/dependencies-view-bs-unit-test-callee-mode-seq-unit-test.png

Natural Unit Test Resources

When a Natural unit test is open in the editor view, the root node displays the name of the unit test. In caller mode (graphics/caller-mode-icon.png), one child node is displayed for each sequence unit test that includes this unit test in one of its test steps. For example:

graphics/dependencies-view-natural-unit-test-caller-mode.png

In callee mode (graphics/callee-mode-icon.png), the child node displays the name of the Natural subprogram that the unit test executes, along with the names of the supporting Natural resources and the names of the libraries and projects in which they are located. For example:

graphics/dependencies-view-natural-unit-test-callee-mode.png