Version: v0.0.0-...-2cabcd1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2022 License: MIT Imports: 9 Imported by: 0





This section is empty.


This section is empty.


This section is empty.


type TestServer

type TestServer struct {
	// contains filtered or unexported fields

A TestServer is a Temporal server listening on a system-chosen port on the local loopback interface, for use in end-to-end tests.

func NewServer

func NewServer(opts ...TestServerOption) *TestServer

NewServer starts and returns a new TestServer.

If not specifying the WithT option, the caller should execute Stop when finished to close the server and release resources.

Example (TestWorker)
package main

import (


// to be used in example code
var t *testing.T

func main() {
	// Create test Temporal server and client
	ts := temporaltest.NewServer(temporaltest.WithT(t))
	c := ts.Client()

	// Register a new worker on the `hello_world` task queue
	ts.Worker("hello_world", func(registry worker.Registry) {

	// Start test workflow
	wfr, err := c.ExecuteWorkflow(
		client.StartWorkflowOptions{TaskQueue: "hello_world"},
	if err != nil {

	// Get workflow result
	var result string
	if err := wfr.Get(context.Background(), &result); err != nil {

	// Print result

Hello world

func (*TestServer) Client

func (ts *TestServer) Client() client.Client

Client returns a Temporal client configured for making requests to the server. It is configured to use a pre-registered test namespace and will be closed on TestServer.Stop.

func (*TestServer) NewClientWithOptions

func (ts *TestServer) NewClientWithOptions(opts client.Options) client.Client

NewClientWithOptions returns a Temporal client configured for making requests to the server. If no namespace option is set it will use a pre-registered test namespace. The returned client will be closed on TestServer.Stop.

func (*TestServer) Stop

func (ts *TestServer) Stop()

Stop closes test clients and shuts down the server.

func (*TestServer) Worker

func (ts *TestServer) Worker(taskQueue string, registerFunc func(registry worker.Registry)) worker.Worker

Worker registers and starts a Temporal worker on the specified task queue.

type TestServerOption

type TestServerOption interface {
	// contains filtered or unexported methods

func WithT

func WithT(t *testing.T) TestServerOption

WithT directs all worker and client logs to the test logger.

If this option is specified, then server will automatically be stopped when the test completes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL