TestWorkflowEnvironment provides workflow unit testing capabilities.
Testing the workflow code is hard as it might be potentially very long running. The included in-memory implementation of the Temporal service supports an automatic time skipping. Anytime a workflow under the test as well as the unit test code are waiting on a timer (or sleep) the internal service time is automatically advanced to the nearest time that unblocks one of the waiting threads. This way a workflow that runs in production for months is unit tested in milliseconds. Here is an example of a test that executes in a few milliseconds instead of over two hours that are needed for the workflow to complete:
Attributes
- See also
-
TestWorkflowEnvironment
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
Value members
Concrete methods
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
Blocks until all tasks have completed execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
Value parameters
- options
-
await termination options
Attributes
Attributes
- See also
-
TestWorkflowEnvironment#close
This time might not be equal to java.lang.System.currentTimeMillis() due to time skipping.
This time might not be equal to java.lang.System.currentTimeMillis() due to time skipping.
Attributes
- Returns
-
the current in-memory test Temporal service time in milliseconds or java.lang.System.currentTimeMillis() if an external service without time skipping support is used
Currently prints histories of all workflow instances stored in the service. This is useful information to print in the case of a unit test failure.
Currently prints histories of all workflow instances stored in the service. This is useful information to print in the case of a unit test failure.
Attributes
- Returns
-
the diagnostic data about the internal service state.
Creates a new Worker instance that is connected to the in-memory test Temporal service.
Creates a new Worker instance that is connected to the in-memory test Temporal service.
Value parameters
- taskQueue
-
task queue to poll.
Attributes
Setup test environment with a guaranteed finalization.
Setup test environment with a guaranteed finalization.
Value parameters
- options
-
await options with polling interval and poll delay
Attributes
Initiates an orderly shutdown in which polls are stopped and already received workflow and activity tasks are executed.
Initiates an orderly shutdown in which polls are stopped and already received workflow and activity tasks are executed.
Attributes
- See also
-
TestWorkflowEnvironment#shutdown
Initiates an orderly shutdown in which polls are stopped and already received workflow and activity tasks are attempted to be stopped. This implementation cancels tasks via Thread.interrupt(), so any task that fails to respond to interrupts may never terminate.
Initiates an orderly shutdown in which polls are stopped and already received workflow and activity tasks are attempted to be stopped. This implementation cancels tasks via Thread.interrupt(), so any task that fails to respond to interrupts may never terminate.
Attributes
- See also
-
TestWorkflowEnvironment#shutdownNow
Wait until internal test Temporal service time passes the specified duration. This call also indicates that workflow time might jump forward (if none of the activities are running) up to the specified duration.
Wait until internal test Temporal service time passes the specified duration. This call also indicates that workflow time might jump forward (if none of the activities are running) up to the specified duration.
This method falls back to Thread.sleep if an external service without time skipping support is used
Attributes
Start all workers created by this test environment.
Start all workers created by this test environment.
Attributes
Concrete fields
Creates a WorkflowClient that is connected to the in-memory test Temporal service.
Creates a WorkflowClient that is connected to the in-memory test Temporal service.
Attributes
Returns the in-memory test Temporal service that is owned by this.
Returns the in-memory test Temporal service that is owned by this.