temporalio / temporalio/sdk-java

Support assertions in `TestWorkflowEnvironment.registerDelayedCallback`

Open
#597 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
433
Forks
249
Avg merge
5d 6h
Merged PRs (30d)
26

Description

Is your feature request related to a problem? Please describe.

When assertions fail in TestWorkflowEnvironment.registerDelayedCallback, the errors in the callback are swallowed. This is counterintuitive.

For instance, I expect the following test to fail.

class MyTest {

  private val testEnv: TestWorkflowEnvironment
  
  @Test
  fun thisShouldFail() {
    testEnv.registerDelayedCallback(Duration.ofSeconds(1)) {
      assertThat(false).isTrue()
    }
    testEnv.sleep(Duration.ofSeconds(10))
  }
}

But it succeeds with an error log.

10:35:11.197 [Timer task] ERROR i.t.i.t.SelfAdvancingTimerImpl - Unexpected failure in timer callback
org.opentest4j.AssertionFailedError: 
Expecting value to be true but was false
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

Describe the solution you'd like
Propagate the error to the test method.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating TestWorkflowEnvironment.registerDelayedCallback and the timer callback handling it. Reproduce the Kotlin example, then trace how callback failures are reported; done means an assertion failure in the delayed callback causes the test method to fail rather than only producing an error log.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.