Packages

class ZTestWorkflowEnvironment[+R] extends AnyRef

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:

See also

TestWorkflowEnvironment

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ZTestWorkflowEnvironment
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. implicit lazy val activityRunOptions: ZActivityRunOptions[R]
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def awaitTermination(options: ZAwaitTerminationOptions = ZAwaitTerminationOptions.testDefault): 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.

    options

    await termination options

  7. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  8. def close: UIO[Unit]

    See also

    TestWorkflowEnvironment#close

  9. def currentTimeMillis: UIO[ZCurrentTimeMillis]

    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.

    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

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  13. def getDiagnostics: UIO[String]

    Currently prints histories of all workflow instances stored in the service.

    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.

    returns

    the diagnostic data about the internal service state.

  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. def namespace: String
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def newWorker(taskQueue: String, options: ZWorkerOptions = ZWorkerOptions.default): UIO[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.

    taskQueue

    task queue to poll.

  19. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  20. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  21. def setup(options: ZAwaitTerminationOptions = ZAwaitTerminationOptions.testDefault): URIO[Scope, Unit]

    Setup test environment with a guaranteed finalization.

    Setup test environment with a guaranteed finalization.

    options

    await options with polling interval and poll delay

  22. 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.

    See also

    TestWorkflowEnvironment#shutdown

  23. 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.

    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.

    See also

    TestWorkflowEnvironment#shutdownNow

  24. def sleep(duration: zio.Duration): UIO[Unit]

    Wait until internal test Temporal service time passes 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

  25. def start: UIO[Unit]

    Start all workers created by this test environment.

  26. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  27. val toJava: TestWorkflowEnvironment
  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  30. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. lazy val workflowClient: ZWorkflowClient

    Creates a WorkflowClient that is connected to the in-memory test Temporal service.

  33. lazy val workflowServiceStubs: ZWorkflowServiceStubs

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

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped