Unit Test the Java Delegates

Do you have a sample of the JavaDelegate that is the class under test? (I assume GatherInformation)
Also do you have a sample for the applicationContext-test.xml file?

Hi, I’m hoping to test the Delegates independently, purely asserting the behaviour within them. The idea would be to pass in the delegateExecution to the Delegate class, where some variables would be read/updated, and then assert these updated variables in the output. Is thispossible in a pure ‘unit’ test, not a ‘scenario’ (integration) test? Thanks

can you provide some examples using camunda-bpm-mockito?

1 Like

Hi,

There are well documented examples in the README of the library located here:

The idea is simple. You instantiate you delegate, and pass mocks for all dependencies. Then you pass an instance of ‘DelegateExecutionFake’ which you prepare before to the ‘execute’ method.

Then you assert the variables changed in the execution and verify the correct invocations on the mock.

The example in the Readme is about DelegateTaskFake, but it is exactly the same principle.

Cheers,

Simon

1 Like

Thanks Simon, I am pretty new to Camunda, can you tell me the difference between camunda-bpm-mockito and camunda-platform-7-mockito? which one should I use?

No problem.

With the release of Camunda Platform 8, Camunda asked the community to change the name of Community extension to reflect the version, it is designed for. So camunda-bpm-mockito became camunda-platform-7-mockito. It is the same library, just having a new name.

Current version of it supports the decent Camunda 7 versions, which is 7.18.x / 7.19.x. It has a magic semantic versioning concept. A camunda-platform-7-mockito 6.18.x is compatible with camunda platform 7.18, camunda-platform-7-mockito 6.19.x supports camunda platform 7.19.
This version matching is important, since the library provides mocks for interfaces, which change slightly from version to version.

Hope this helps. If you have any questions, don’t hesitate to ask. Have a look on the README of the library, if additional help is required, just ask…

Cheers,

Simon

1 Like

Thanks Simon, I was able to create testcases for JavaDelegates using camunda-platform-7-mockito.

1 Like