Unit test with external task

Hi, guys!

I want to know, how dependencies I need with maven repository and how i do unit test in camunda with external task in java. I want to enter inside of handle method.

Thank you,

Fernando.

Hi @fernando123,

you can use the maven dependencies mentioned in the docs here: https://docs.camunda.org/manual/7.12/user-guide/testing/#camunda-assertions.

In your JUnit tests you can write:

assertThat(processInstance).isWaitingAt("SendNotificationTask").externalTask().hasTopicName("notification");
complete(externalTask());

If needed, you can pass variables in the compete() method as well:

compete(externalTask(), withVariables("resultVar1", "Value1", "resultVar2", true));

All helpers and assertions are listed here: https://github.com/camunda/camunda-bpm-assert/blob/master/docs/User_Guide_BPMN.md

Hope this helps, Ingo

Hi Ingo!

I need just cover my code, i need to see the whole class, IĀ“m java programmer i donĀ“t know camunda. What i want itĀ“s a test class just cover my code and enter into method handle of external task in a topic call.

Thanks,

Hi guys!

when i do the test and pass from the code
runtimeService.startProcessInstanceByKey(ā€œAtualizarEmpresaTaskTestā€);
return null, why this is happen?
What does mean startProcessInstanceByKey, and what value I put in this field?

thanks.

Hi you, I had the same problem, donā€™t know if youā€™ve solved it yet?

1 Like

I download other bpmn in the internet and works, I think is the bpmn file, but I need create a process instance without start an instance with bpmn file, thereĀ“s a way to do this?

I solved this issue, I openned the bpmn and I Copied the field id and paste

runtimeService.startProcessInstanceByKey(ā€œfield id of bpmnā€);