I’m new to Camunda, and I need to test the Java Delegates in the solution. All that I’ve found out there are ways to test the process mocking the delegates. But what I want to create are test cases for the Delegate itself.
Is this something that can be done? If so, could you provide an example or point to a resource I can look at? Am I missing the point of unit testing processes in Camunda?
Can you please post sample code for junit testing.
I am facing some issue while calling delegateExecution.getVariableTypes , getting null pointer execption.
Hi, Were you able to get it work? I see here that “myVariable” is mocked to return myValue and that is asserted to true, which would be always true regardless of calling gatherInformation.execute(execution) .
I see here that “myVariable” is mocked to return myValue and that is asserted to true, which would be always true regardless of calling gatherInformation.execute(execution).
How can we make sure that gatherInformation.execute(execution) works as expected?
Assuming gatherInformation.execute(execution) performs some logic and uses the execution parameter, use verifications to check it actually invoked the correct methods on the execution.
For me most of the time the use case is, pass some execution variables and do some business log, get the JSON / XML kind of result then parse it, and set on the execution variables.
Since we mock execution and its variables, there is no way that the test would fail. any pointers on my case?
It would fail if you verify that some value is set on the execution. If the implementation is wrong, that would not be done and the verification would fail. It’s basic, but still.
I understand, but that’s also not what I mean. I mean to say that if you know your implementation should do something with the execution it is passed, it’s something you can verify against the mock. So, if your implementation should call e.g. execution.setVariable(“abc”, someObject), you can verify that it was actually done.
With mocking frameworks, you can verify that certain interactions were executed with the mock itself. With Mockito for instance, assuming “execution” is a mock object you created, you can do:
Sorry no, I’m not even sure that part of the engine is pluggable so mocking it would be complicated. Why would you want to do that, if you can just put the actual value in the process?