The DMN Test lab

With the DMN Test lab, you define and run test cases in order to check whether a DMN diagram fulfills certain requirements. For example, you can ensure that diagrams still comply with the initial decision logic after being extended, and you can control the correctness of specific input combinations and outputs in complex diagrams.

The DMN Test lab

Create test cases

To open the Test lab, select the diagram you want to test in the explorer and click Edit > Test DMN diagram.

To create a new test case, follow these steps:

  1. Click '#' on the left of the test cases table.

  2. Click one of the test case's columns to define all its values. A drop-down dialog opens and you can enter the necessary information. Then, click Apply.
    Specify the input data of your test case.
  3. Click the column that shows the calculated value in red in the Result column on the right and specify the expected output value(s).

    Specify the expected output value(s)

After you have created all necessary cases, you can save them by clicking the Save button.

To delete a test case, it must be saved first. To do so, click onto the number of the saved test case(s) you would like to remove, then click Save.

Delete a test case.

Each test case is automatically executed as soon as a parameter is changed.

In the following simple case, we want to determine a discount. The only input parameter here is the purchase value. In the first test case, no value is given for the expected result as indicated by the red X on the left in the result column. In the second case, the actual discount corresponds with the expected result as indicated by the green check mark icon. In the third case, the expected result is different from the actual result, as indicated, again, by the red X.

Undefined, passing and failing test cases

 

Inspecting test cases in the simulation tool

Often, you want to find out why a test case is producing a certain output. With the DMN simulation you can inspect a decision's behavior, for example to see exactly which rules fire for your input data set. To open the simulation tool, select a test case and click Inspect in Simulation:

Open a test case in the simulation tool.

Then, the simulation tool applies the input data of your test case automatically.

Import and export test cases

To keep test cases when exchanging diagrams between SAP Signavio workspaces or using the test cases in other tools, you can export and import the test cases as JSON files.

You need to save test cases to be able to export them.

To export test cases for a diagram, open the Test lab and click Export Test Cases. The file is saved to your browser's download folder. By default, the file is named after the diagram.

To import test cases, follow these steps:

  1. Open the Test lab and click Import.

  2. Select the JSON file you want to import and click Open.

    The test cases are imported and added to the test cases you have already created.

Import test cases from third-party tools

You can import test cases created in other software tools. To do this, you must convert the test cases into the format supported by the Test lab. We recommend creating a template JSON file for test cases and adding the existing test cases to it.

To create a template, add your test cases, and import the test cases, follow these steps:

  1. Open the Test lab and create a test case as described in section Create test cases.

  2. To get a format template for a test case, enter one example for inputs and expected outputs.

  3. To get the IDs of the values, enter examples for enumerations and attributes of complex data types.

  4. To export the template file, click Export Test Cases.

    The file is saved to your browser's download folder.

  5. Open the template file in any editor and add your test cases to the testCases section.

    Before you start customizing the template file, we recommend creating a copy as backup.

    Read more on the file structure in section Structure of a test cases file.

  6. Save your changes in the file and return to the Test lab.

  7. To import the file with your test cases, click Import.

  8. Select the file and click Open.

    Your test cases are imported and added to the test cases you have already created.

Structure of a test cases file

A test cases file is structured as follows:

{
    "inputParameterDefinitions": [
        {
            "id": "DIAGRAM_ID/SHAPE_ID",
            "shapeId": "SHAPE_ID",
            "diagramId": "DIAGRAM_ID",
            "modelName": "MODEL_NAME",
            "requirementName": "INPUT_DATA_NAME"
        },
        ...
    ],
    "outputParameterDefinitions": [
        {
            "id": "DIAGRAM_ID/SHAPE_ID",
            "shapeId": "SHAPE_ID",
            "diagramId": "DIAGRAM_ID",
            "modelName": "MODEL_NAME",
            "requirementName": "TOP_LEVEL_DECISION_NAME"
        },
        ...
    ],
    "testCases": [
        {
            "inputValues": [
                {
                    "type": "number|string|date|time|datetime|boolean|complex|enumeration|hierarchy|list",
                    "value": "INPUT_VALUE"
                },
                ...
            ],
            "expectedValues": [
                {
                    "type": "number|string|date|time|datetime|boolean|complex|enumeration|hierarchy|list",
                    "value": "OUTPUT_VALUE"
                }
            ]
        },
        {
            <ANOTHER TEST CASE>
        },
        {
            <ANOTHER TEST CASE>
        },
        ...
    ]
}

For convenience, the Test lab export adds name elements, for example name, modelName, and requirementName, to add context to the exported file. The name elements aren't imported. However, you must not change any name element, otherwise the import will fail.

Besides these name elements, all elements in the test cases file are required, otherwise the import will fail.

Definition of input and output parameters

Element Description Type
  • inputParameterDefinitions

  • outputParameterDefinitions

Top level Array of definition objects for input or output parameters
  id

Specifies the ID of the parameter definition

The ID is composed of the diagram ID and the shape ID as follows: diagramID/shapeID

String
  shapeId

Specifies the ID of the shape

To find the shape ID, open the DMN diagram in the editor and expand the attributes panel. Under More Attributes, the shape ID is listed as Element ID.

String
  diagramId

Specifies the ID of the DMN diagram

The diagram ID is part of the URL when opening the DMN diagram in the editor, for example id=343056b7ce194785b04efab05cfa92a9 from the URL https://<your_workspace>.signavio.com/p/editor?id=343056b7ce194785b04efab05cfa92a9.

String
  modelName

Specifies the title of the diagram as specified in the editor

This element is ignored during import.

String
  requirementName

For inputParameterDefinitions: Specifies the shape name of an input data element.

For outputParameterDefinitions: Specifies the shape name of the top-level decision element.

This element is ignored during import.

String

List of test cases

Element Description Type
testCases Top level Test cases object
  inputValues

Specifies the input data

inputValues is bound to the input data via the section inputParameterDefinitions. The order defines the binding: the first element in inputValues is passed as value to the input data corresponding to the first element in inputParameterDefinitions.

Array of input value objects, read more in section Objects for input and output values
  expectedValues

Specifies the expected output data

expectedValues is bound to the decision output via the section outputParameterDefinitions. The order defines the binding: the first element in expectedValues is passed as value to the output data corresponding to the first element in outputParameterDefinitions.

Array of output value objects, read more in section Objects for input and output values

Objects for input and output values

Element Description Type Notes
  • inputValues

  • expectedValues

Top level Array of input or output value objects  
 type Specifies the data type of the input or output value

String

Valid values:

  • number

  • string

  • date

  • time

  • datetime

  • boolean

  • complex

  • enumeration

  • hierarchy

  • list

 value Specifies the actual input or output value String

The data types "number", "string", and "boolean" correspond to standard JSON data types.

Values of type "date" must be represented as ISO formatted strings, for example "2015-12-31".

Values of type "time" must be represented as ISO formatted string, for example "T23:59:59Z" or "T23:59:59-02:00".

Values of type "datetime" must be represented as ISO formatted string, for example "2015-12-31T23:59:00-02:00".

For values of type "list", read more in section List value. Nesting lists is not supported.

For values of type "complex", read more in section Complex value.

For values of type "enumeration", read more in section Enumeration value.

For values of type "hierarchy", read more in section Hierarchy value.

List value

JSON example:

{
  "type" : "list",
  "value" : [ {
    "type" : "number|string|date|time|datetime|boolean|complex|enumeration|hierarchy",
    "value" : "INPUT_VALUE"
  }, {
    "type" : "number",
    "value" : "INPUT_VALUE"
  }, {
  ...
  } ]
}
Element Description Type
type

Specifies the data type of a value.

Value must be "list".

String
value Specifies the list value objects Array of value objects, read more in section Objects for input and output values

Nesting lists is not supported.

Complex value

JSON example:

{
  "type" : "complex",
  "slots" : [ {
    "id" : "0",
    "value" : {
      "type" : "number|string|date|time|datetime|boolean|complex|enumeration|hierarchy|list",
      "value" : "INPUT_VALUE",
    }
  }, {
    "id" : "1",
    "value" : {
      "type" : "number|string|date|time|datetime|boolean|complex|enumeration|hierarchy|list",
      "value" : "INPUT_VALUE",
    }
  }, {
  ...
  } ]
}
Element Description Type
type

Specifies the type of a value

Value must be "complex".

String
slots Specifies the attributes of the complex type definition Array of attribute objects
  id

Reference to the value of the data type definition

Since attributes can be renamed and reordered, the name or the order as shown in the editor can be misleading. IDs are assigned when a new attribute is created. Renaming and reordering doesn't change the attribute's ID. To determine the correct ID, export an example test case for each value.

String
  value

Specifies the actual value for the attribute

Value object, read more in section Objects for input and output values

Enumeration value

JSON example:

{
  "type" : "enumeration",
  "value" : "0"
}
Element Description Type
type

Specifies the data type of a value

Value must be "enumeration".

String
value

Specifies the ID of the value of the data type definition

Since enumeration values can be renamed and reordered, the name or the order as shown in the editor can be misleading. IDs are assigned when a new enumeration value is created. Renaming and reordering doesn't change the enumeration value's ID. To determine the correct ID, export an example test case for each value.

String

Hierarchy value

JSON example:

{
  "type" : "hierarchy",
  "value" : [ "1", "4" ],
}
Element Description Type
type

Specifies the data type of a value

Value must be "hierarchy".

String
value

Specifies a list of IDs according to the data type definition, constructing the path from the root of the hierarchy to the referenced element

Since hierarchy values can be renamed and reordered, the name or the order as shown in the editor can be misleading. IDs are assigned when a new hierarchy value is created. Renaming and reordering doesn't change the hierarchy value's ID. To determine the correct ID, export an example test case for each value.

Array of positional IDs