Is there any way to configure Workflow Options in Java Testing SDK?


In my test I’ve gotten a bug in the workflow code itself (not the activities), and the service just tried to run it over and over again… I would like to provide Workflow Options (at least in the test environment) to make sure such cases will fail the test instead of trying forever… but I have found no way to do that using the TestWorkflowExtension. Is there a way do to such config?

Assuming you are currently registering your workflow impls via TestWorkflowExtension->setWorkflowTypes.
One thing you can do is for example:

  public static final TestWorkflowExtension testWorkflowExtension =

and then in your test method set fail workflow exceptions via WorkflowImplementationOptions, for example:

  public void myTestMethod(
      TestWorkflowEnvironment testEnv, Worker worker) {
    worker.registerActivitiesImplementations(new MyActivitiesImpl());
    // ...

     MyWorkflow workflow = testEnv
       // ...

If you want your workflow to fail on any exception type, you could set FailWorkflowExceptionTypes to Throwable.class.

Hope this helps.

1 Like