Blog Posts BPMN DMN

How to use Test Scenario Editor to test your DMN asset in VSCode

Blog: Drools & jBPM Blog

Introduction

Testing an asset is a crucial phase for most human activities. As humans, we are able to define very complex algorithms and to design intricated domains with several different possible states. There are no boundaries on what we can create and design. On the other side, as humans, we make mistakes. It represents the main friction to our creativity. Usually, during a creative activity, questions like the following may arise:

A reasonable answer for these questions is to create and rely on a strong Testing phase. In my previous article, I described how to create a DMN asset to include a PMML file. How can we actually check if the resulting DMN file satisfies our expectations? Our Kogito Tooling suite now offers the Test Scenario editor, a tool already present in Business Central, which enables DMN Editor users to test their created DMN files.
Consequently, the aim of this article is to guide you through a step-by-step tutorial describing how to create and use the Test Scenario editor to test the DMN file previously created.

Tutorial

Here, required elements for this guide:

Project setup

Cloning and using our example

Exactly in the same way described in my previous article, we need to clone kogito-examples repository, open your VSCode editor and go to the kogito-examples/dmn-pmml-quarkus-example directorywhich contains the covered example. As a result, you should see the project open in VSCode, as shown in the below screenshot:

VSCode editor after opening kogito-examples/dmn-pmml-quarkus-example project

The resulting project contains all required files and prerequisites for this tutorial.

Creating a new project

In case we want to create a new project from scratch, we need to focus on four mandatory prerequisites required to correctly use the Test Scenario:

 $ mvn archetype:generate 
    -DarchetypeGroupId=org.kie.kogito 
    -DarchetypeArtifactId=kogito-quarkus-archetype 
    -DgroupId=org.acme -DartifactId=sample-kogito 
    -DarchetypeVersion=1.5.0.Final 
    -Dversion=1.0.0-SNAPSHOT
<dependency>
  <groupId>org.kie.kogito</groupId>
  <artifactId>kogito-scenario-simulation</artifactId>
  <scope>test</scope>
</dependency>
package testscenario;

@org.junit.runner.RunWith(org.kogito.scenariosimulation.runner.KogitoJunitActivator.class)
public class KogitoScenarioJunitActivatorTest {

}
KogitoScenarioJunitActivatorTest.java in VSCode

Creating a new Test Scenario

Great! All prerequisites are now set, therefore we are now ready to create our first Test Scenario file! As previously mentioned, the goal is to create a Test Scenario to test “KiePMMLRegression.dmn” DMN asset. Here, the steps:

Create Test Scenario popup
Create a Test Scenario for KiePMMLRegression.dmn
Test Scenario structure for”KiePMMLRegression.dmn
Test Scenario filled with a first scenario case
Test Scenario filled with four scenario cases

Executing the Test Scenario

Excellent! It’s now time to run the Test Scenario file, in order to verify the filled scenario is correct.

mvn clean test
A maven build will start and during its test phase, all defined scenarios will be verified using the Test Scenario runner. With previously filled data, the four defined scenarios should pass successfully as shown in the screenshot below:
Running a Test Scenario launching mvn clean test command
Resulting Java Test Report
KogitoScenarioJunitActivatorTest #1 First Case: Failed in "Decision": The expected value is "54.7" but the actual one is "52.5" (KiePMMLRegressionTest)
Test Result with wrong data

Conclusion

With this article, we learned how to test a DMN asset using a Test Scenario Editor, part of DMN Editor VSCode plugin. Undoubtedly, it represents a valid tool to support the creation and the analysis of your DMN assets, which should be strongly considered to increase their robustness and reliability.

Another useful resource you can refer to is MODELING AND DEVELOPMENT OF DECISION SERVICES: DMN WITH KOGITO article, by Matteo Mortari. Here, you can find a very exhaustive video where Matteo creates a Test Scenario following the same steps described in this article.

And if this is still not enough, you can refer to our documentation, which contains a section on Testing the decision logic for a Kogito service using test scenarios.

Thank you for reading!

The post How to use Test Scenario Editor to test your DMN asset in VSCode appeared first on KIE Community.

Leave a Comment

Get the BPI Web Feed

Using the HTML code below, you can display this Business Process Incubator page content with the current filter and sorting inside your web site for FREE.

Copy/Paste this code in your website html code:

<iframe src="https://www.businessprocessincubator.com/content/how-to-use-test-scenario-editor-to-test-your-dmn-asset-in-vscode/?feed=html" frameborder="0" scrolling="auto" width="100%" height="700">

Customizing your BPI Web Feed

You can click on the Get the BPI Web Feed link on any of our page to create the best possible feed for your site. Here are a few tips to customize your BPI Web Feed.

Customizing the Content Filter
On any page, you can add filter criteria using the MORE FILTERS interface:

Customizing the Content Filter

Customizing the Content Sorting
Clicking on the sorting options will also change the way your BPI Web Feed will be ordered on your site:

Get the BPI Web Feed

Some integration examples

BPMN.org

XPDL.org

×