ZTestWorkflowEnvironment

zio.temporal.testkit.ZTestWorkflowEnvironment
See theZTestWorkflowEnvironment companion object

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 Object
trait Matchable
class Any

Members list

Concise view

Value members

Concrete methods

def awaitTermination(options: ZAwaitTerminationOptions): UIO[Unit]

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.

Attributes

options

await termination options

def newWorker(taskQueue: String, options: ZWorkerOptions): ZWorker

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.

Attributes

taskQueue

task queue to poll.

def setup(options: ZAwaitTerminationOptions): URIO[Scope, Unit]

Setup test environment with a guaranteed finalization.

Setup test environment with a guaranteed finalization.

Attributes

options

await options with polling interval and poll delay

def shutdown: UIO[Unit]

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

def shutdownNow: UIO[Unit]

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

def start: UIO[Unit]

Start all workers created by this test environment.

Start all workers created by this test environment.

Attributes

Deprecated methods

def use[E, A](options: ZAwaitTerminationOptions)(thunk: ZIO[R, E, A]): ZIO[R, E, A]

Allows to run arbitrary effect ensuring a shutdown on effect completion.

Allows to run arbitrary effect ensuring a shutdown on effect completion.

Shutdown will be initiated when effect either completes successfully or fails (with error or defect) The effect will return after shutdown completed

Attributes

options

await options with polling interval and poll delay

Deprecated
[Since version 0.2.0]

Concrete fields

val toJava: TestWorkflowEnvironment
lazy val workflowClient: ZWorkflowClient

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

lazy val workflowService: ZWorkflowServiceStubs

Returns the in-memory test Temporal service that is owned by this.

Returns the in-memory test Temporal service that is owned by this.

Attributes

Implicits

Implicits

implicit lazy val activityOptions: ZActivityOptions[R]