Cannot resolve identifier error in unitTest

Hi
I wrote a unitTest for my model.
And everything was fine.
I added a string form for first userTask, and called that form variable in “Element Documentation” section for second userTask.
And now, when i run the unitTest, test failed by this error:

org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: some description ${myVariable} Cause: Cannot resolve identifier 'myVariable'

Please guide me

Can you upload the model and the unit test?

1 Like

@Niall
I’m sorry but I can’t upload the model and unit test exactly.

I’ll upload a similar bpmn and write unit test.
diagram_1.bpmn (4.2 KB)

private fun inUser2(processInstance: ProcessInstance): State {
    assertThat(processInstance).task("user2")
    return State.end
}

If these aren’t clear and don’t mention my point, please tell me to upload original model and unitTest in Private Message.

So what is the intention of that code? are you trying to complete the task, assert the current state or both?

1 Like

I just want to complete the userTask2.
but when I run the unit test, I face by this error:
org.camunda.bpm.engine.ProcessEngineException: Unknown property used in expression: some description ${myVariable} Cause: Cannot resolve identifier 'myVariable'

I used the “myVariable” in Element Description section in userTask2.

Ok, so the variable you’ve defined in the user task will only be created by a user who can operate a front end. This isn’t unusual. In most cases in a Unit Test you’re testing the process not the front end. So you simply need to add the variable when you complete the task.
The camunda bpm asserts documentation is pretty good at explaining this but even better is this talk that @tmetzke gave at camunda con this year which details how to use the API.

1 Like

@Niall

Thank you.
You mean, can I define a form variable in userTask1 and use that variable in Element Description for userTask2 and I write unit test like this:

private fun inUser2(processInstance: ProcessInstance): State {
assertThat(processInstance).task("user2")
complete(task(processInstance), withVariables("myVariable", ""))
return State.end

}

Yes, Exactly.

1 Like