Process Test Coverage and Spring together?

We use Spring in our production code, and to make the most out of that I wan’t to use Spring to some extend in our tests as well.

I have successfully refactored our tests to spring test, using the many available examples of that.

We had a very nice workshop with @falko.menge where we configured tests with coverage. But I have not been able to find out how to combine the camunda-bpm-process-test-coverage extension with Spring testing.

Can I get any hints on how to do that?

I tried it myself here:
https://github.com/lldata/camunda-bpm-spring-boot-starter/commit/2acc51ffe8d683e5466a4dec1c9ed1074ac6698d

My SpringProcessTest works fine. But SpringProcessWithCoverageTest does not.

I just tried to copy some of the event listeners from bpm-process-test-coverage into my spring configuration (in SpringProcessWithCoverageEngineConfiguration.java)

When I run the test it logs " WARNING: Coverage history event listener in use but no coverage run state assigned!"

  • that should give a hint. But the whole initialization code of the coverage plugin it quite hard to follow, for a camunda newbie like me.

Any help and hints appreciated.

Thanks
/Lasse

Hi,

Have you tried configuring the process engine configuration as done here: https://github.com/camunda/camunda-bpm-process-test-coverage/blob/master/test/src/test/resources/camunda.cfg.xml

Perhaps your use case doesn’t work well with our ProcessCoverageInMemProcessEngineConfiguration class. This class is more of a convenience class avoiding the xml configuration from the previous link.

Cheers,
Irmin

I tried having the xml file, but that causes the process engine to be created twice, since it is already configured by Spring.

I just spend an hour cloning the coverage plugin, and adding constructors to the TestCoverageProcessEngineRule that allows me to provide a process engine instance.

It doesn’t work yet. It seems like it is assumed a lot of places that the process engine is configured internally…

I managed to get it to work. I made a pull request to the coverage plugin, to add a bit flexibility to the processengine creation:

2 Likes

The xml is the only configuration you should need.

If you need to obtain the ProcessEngine call https://docs.camunda.org/javadoc/camunda-bpm-platform/7.5/org/camunda/bpm/engine/test/ProcessEngineRule.html#getProcessEngine() . It is not necessary to @Inject (or @Autowire) another process engine.

ProcessEngineRule is the super class of the coverage rule.

Is there a detail that I am missing?

I am just saying that I’d prefer it, if it was possible to do without the xml configuration.
And now it is (or will be, when my pull request gets merged)

Spring Java Configuration is much more elegant and flexible than the xml files, so we try to get rid of them whenever we can,

Hi, I need to perform bpmn coverage test using Spring, can you post me some sample test, please?

Sorry for the long delay. I have an example linked if you follow the link from my pull request above.
Because of forum rules I couln’t add more links to this thread :-S

Example:
https://github.com/lldata/camunda-bpm-spring-boot-starter/tree/master/examples/example-simple/src/test/java/org/camunda/bpm/spring/boot/starter/example/simple

The example depends on this pull request:

1 Like

thanks for reply! At moment we have stopped this thread but I’m today interested, I will retry as soon :wink:

Hi @devj87! This already works. See "Process Test Coverage” v0.2.9 and “Scenario” v0.2 released!

1 Like