Verify incident is created in case of error while testing camunda process

How can I verify that’s incident is created in case of boundaryError while testing camunda process? I want to verify incident from my H2 db in my unit test. I have tried to verify using below services.
runtimeService.createIncidentQuery().processInstanceId(id).orderByIncidentMessage().asc().singleResult()
historyService.createHistoricTaskInstanceQuery().processInstanceId(id)
but it gives null response. Kindly if someone can help me in this.

Hello @zeeshanameer ,

when using the error boundary event, no incident will be created as this is regarded as business error and can be handled by the process itself.

So if you want to verify that a business error was triggered, verify that the process instance is waiting at the next wait state after the boundary event.

I hope this helps

Jonathan

buinsess_error
@jonathan.lukas here in picture I’m creating business error now want to verify that’s it is created and saved in H2 database

Hello @zeeshanameer ,

you can verify this by asserting that the process instance is waiting at user task “Review lsv Output” and has the variable with the value of the error code and/or message that you assigned it to.

Jonathan