Unit Test Configuration(4.3)

Use the Unit Test configuration to write unit tests for APL code in Python code language. Use the Unit Test Runner(4.3) to run the unit tests.

Unit Test configuration

Enter code in the code area. Below the text area there are line, column and position indicators to help you find syntax errors.

For information on how to import code into the code editor, see Importing Code.

Function blocks

Unit Test code is divided into different function blocks that serve as execution entry-points. The Unit Test contains initialize, denitialize, and test function blocks. If a function block begins with "test" it is a test function block.

A simple test to illustrate how it works below. We create a en error in the initialize block, then we have the actual test where we find the log id from the log, and at last we remove the log entry in the deinitialize block.

Example

from time import sleep

logid = None

def initialize():
    print('test starting')
    logError('Something bad has happened')
    
def test_find_new_log():
    global logid
    sleep(5)
    myit = logSearch(toDate=drdate.now(), fromDate=drdate(drdate.now().timestamp - 60), severities=['Error'])
    for x in myit:
        logid= x['Id']
        print(x)
 
def deinitialize():
    print('Removing the new log entry')
    logRemove(logid)
    myit = logSearch(toDate=drdate.now(), fromDate=drdate(drdate.now().timestamp - 60), severities=['Error'])
    for x in myit:
        print(x)

Internal Unit Test Functions

For the internal Unit Test functions see Unit Test Functions(4.3).

Toolbar

The toolbar includes the following options:

OptionDescription
New

Creates a new Unit Test configuration in a new tab. You can only create a configuration of the same kind as the one in the tab you are working in.

OpenOpens a saved configuration that is visible in a new tab. You can only open a configuration of the same kind as the one in the tab you are working in.
Save

Saves the configuration.

After you click Save, a dialog box opens. In the Version Comment text box, you can enter a description of the changes that you have made, then click OK

Save As

Select to save the configuration with a new name. You can only use a-z, A-Z, 0-9, "-" and "_" to name a configuration.

After you click Save As, a dialog box opens. Select in which folder to save the configuration. In the Version Comment text box, you can enter a description of the changes that you have made, then click OK

PermissionsSet the owner of the configuration as well as Read, Write and Execute permissions for the groups accessing the configuration. 
ValidateValidates the current Unit Test code. The status of the validation is displayed in a dialog. Upon failure, the erroneous line is highlighted and a message, including the line number, is displayed.
References

Select to see the Reference Viewer listing references to and from the active configuration. The Reference Viewer includes the following tabs:

  • Used By: Displays a list of other configurations that refer to the configuration. For example: a workflow group that refers to a workflow.

  • Uses: Displays a list of other configurations that the configuration refers to. For example: a workflow configuration that refers to a specific profile.

  • Access: Displays the group of users that may access the configuration, and the user that created (owns) the configuration.

HistoryDisplays a drop-down list with file changes in the lower section of the window. If a file is selected, comments related to the file change are displayed.
UndoSelect this option to undo your last action.
RedoSelect this option to redo the last action you "undid" with the Undo option.
CutCuts your selection and copies it to the clipboard.
CopyCopies selection to the clipboard.
PastePastes the clipboard contents.
FindDisplays a dialog where you can search for text and, if required, replace it.
Find AgainRepeats the search for the last string entered in the Find dialog.

Unit Test Code Editor Assistance

To provide assistance when writing code in the Unit Test code area, there are several features in place:

Syntax Highlighting - Different parts of the code are color coded according to type

Right-Click Menu - A menu which provides editor options

Code Completion - Code Completion which helps you to write Unit Test code in the Code Editor by providing context-sensitive proposals.

Code Editor Outline - An outline navigation panel to make it easier to navigate in a Unit Test code configuration

For further information, see Code Editor Assistance.

Code Editor Outline

To make it easier to navigate in a Unit Test code configuration, there is an Outline navigation panel to the right of the Code Editor.

The Code Editor Outline provides a view of all the blocks, variables and methods in a Unit Test code configuration and makes it possible to easily navigate between different types in the Unit Test code. The entries in the navigation panel are automatically updated as you make valid entries in the Code Editor.

You can also filter what you want to display in the Outline navigation panel. You can search for a specific block, variable, or method using the free text field, or by selecting one of the quick filter buttons:

b

Click to display or hide the blocks within the Unit Test code configuration displayed in the Code Editor.

v

Click to display or hide the variables within the Unit Test code configuration displayed in the Code Editor.

m

Click to display or hide the methods within the Unit Test code configuration displayed in the Code Editor.

The Outline navigation panel can be hidden or visible. By default, it is visible and all the elements are displayed. To hide or display the navigation panel, click the vertical Outline button to the right of the Code Editor.

Configuration Diff Panel

To compare the current version of a Unit Test configuration that is displayed with a previous version of the same configuration, use Configuration Diff to compare the two versions side by side.

To hide or display the Configuration Diff panel, click the Diff button to the right of the Code Editor. The panel can be hidden or visible. By default, it is hidden.

Navigate through the differences by scrolling both panes in parallel using the scroll bar to the right of either pane. To scroll through each pane separately, hover over the pane to scroll through, and use the scroll wheel on your mouse.

To skip through each difference in the panes, use the navigation buttons, Previous, Next, and Refresh, which are described below.

ItemDescription
History

Click the History drop-down box to select the version to compare.

You can also display and view encrypted configurations. If you select an encrypted configuration, you are prompted to enter the relevant password to decrypt the configuration.

Previous

Click this button to skip to the previous difference in the configurations. The previous difference is highlighted in green.

Next

Click this button to skip to the next difference in the configurations. The next difference is highlighted in green.

Refresh

 

Click this button to display the updated version of the configuration. Configurations are not locked when displayed in Configuration Diff. If another user has modified and saved a configuration that you are viewing in this tool, click this button to view the latest updated version.