How to write unitTest for checking variables value?

Hi
I wrote some unitTests for my processes.
In userTask I used form and in unitTest I wrote complete(task) and I checked variable for that form I created before.
something like this :

complete(task(processInstance), withVariables("confirmation", "ok" ))

and everything was cool.
For now, I want to check the confirmation variable with numbers.
What I want, is checking the condition, if confirmation value is bigger than 10, return to userTask 1.
And if confirmation value is shorter than 10 return to userTask 2.

Hi @rezza72,

What I want, is checking the condition, if confirmation value is bigger than 10, return to userTask 1.
And if confirmation value is shorter than 10 return to userTask 2.

that sounds like a gateway in the process model and should not be done in the JUnit-Test.

If you want to check the value of a variable in the test, you can write something like

assertThat(processInstance).isWaitingAt("invokeSecondServiceTask")
     .variables().contains(entry("shouldFail", false));

Hope this helps, Ingo

1 Like

Hi
Can’t we set a static value for confirmation in first of our code and check that with the code which I wrote in first post ??

Hi @rezza72,

I didn’t understand your question completely.

withVariables("name", value) will only set the value. But you can use every Object that provides a value.

For assertions on variable values see my earlier post.

Hope this helps, Ingo