Unit test not finding DMN file

Hi there

Trying to run this unit case:

@ExtendWith(ProcessEngineExtension.class)
public class DummyActionsDMNTest {
    private ProcessEngine engine;

    @Test
    public void shouldEvaluateDecision() {
        engine.getDecisionService().evaluateDecisionTableByKey("DecisionTable_1d8j7zh", Variables.createVariables()
                .putValue("test", "1"));
    }

}

Snippet from my DMN

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="Definitions_1r0cwkc" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="4.5.0">
  <decision id="actions" name="Actions">
    <decisionTable id="DecisionTable_1d8j7zh" hitPolicy="COLLECT">
      <input id="Input_1" label="Request Type">
        <inputExpression id="InputExpression_1" typeRef="integer" expressionLanguage="javascript">

I have tried various versions of evaluateDecision* method with the various ids, names etc, nothing seems to hit?

Edit 1: Running Camunda 7.17 and JUnit 5
Edit 2: The DMN runs fine when deployed to server, its only the @Test that it does not seem to load

Hi,

You can use the Deployment annotation at your test class to deploy the DMN model:

@ExtendWith(ProcessEngineExtension.class)
@Deployment(resources = {"your.dmn"})
public class DummyActionsDMNTest {
    private ProcessEngine engine;

    @Test
    public void shouldEvaluateDecision() {
        engine.getDecisionService().evaluateDecisionTableByKey("DecisionTable_1d8j7zh", Variables.createVariables()
                .putValue("test", "1"));
    }

}
2 Likes

Perfect, thank you!