Is there a way to start a unit test from the middle of the flow?

Hello community, I’m building some unit tests where my flow is something like A-B-C-D-E , but I would like to know if there’s a way to starting testing from C-D-E instead of A-B-C…

Thanks in advance

1 Like

@devBunny, you can try something like below:

public void startAtSpecificActivity() {
    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()


To start after parallel gateway:

ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
1 Like

Hey @devBunny,

maybe you want to have a look at our Camunda BPM Assert examples we showcased at CamundaCon 2019, it is specifically addressing those issues.

Feel free to watch the accompanying video as well:

Basically, what @aravindhrs proposes works fine. However, if you want to start your instance directly at a specific point instead of regularly starting it and then modifying it afterwards, you can use something like

  public void shouldDoWhateverYouSayItShould() {
    // given
    ProcessInstance instance = runtimeService()
    // when
    // then

Hope that helps.



Thank you.

Thank you!