Process Variables are not updated

Is there a way to update the value of a Process Variable through a unit test after a process instance has been created?

We have been trying to use the runtimeService() to do so but it doesn’t work.

The value of the variable in the Execution Listener scope stays unmodified containing the previous value.

final ProcessInstance processInstance = runtimeService().startProcessInstanceByKey(PROCESS_KEY, BUSINESS_KEY,
                Map.of("Name, "name 1"
                        , "Stage", "stage"



runtimeService().setVariable(processInstance.getId(), "Name, "name 2");


Could someone please point us in the correct direction.