camunda / zeebe-process-test

Testing project for Camunda Platform 8
39 stars 14 forks source link

Forced to use waitForIdleState on each test #1131

Open melohagan opened 4 months ago

melohagan commented 4 months ago

Description I'm quite new to Camunda so I'm not sure if this is my own lack of experience, or if this can be handled in a slightly better way.

Currently I've found that my tests only pass when I use the engine.waitForIdleState method before doing assertions. As this is always needed, could this not be abstracted into the testing library itself?

This is my workaround at the moment:

// resolve task
client.newCompleteCommand(job.key)
            .variables(variables)
            .send()
            .join()

// assert when the task has completed
assertWhenIdle {
            BpmnAssert.assertThat(instance)
                .hasPassedElementsInOrder(<..>)
}

With a base class that has the assertWhenIdle method:

protected fun assertWhenIdle(assertions: () -> ProcessInstanceAssert) {
        // Wait for currently running tasks to complete
        engine!!.waitForIdleState(Duration.ofMillis(Constants.IDLE_TIMEOUT_MILLIS))

        // Run assertions
        assertions()
    }

Am I doing something wrong? It doesn't seem ideal that I'm forced to add in the wait for idle state for every assertion in my test suite.

saig0 commented 1 month ago

[!Note] Heads up! We are building a new Java testing library for Camunda 8.6. The new library will replace Zeebe Process Test. Read more about upcoming changes here and stay tuned for updates. :rocket: