package grpctest

import "google.golang.org/grpc/internal/grpctest"

Package grpctest implements testing helpers.

Index

Variables

var TLogger *tLogger

TLogger serves as the grpclog logger and is the interface through which expected errors are declared in tests.

Functions

func RunSubTests

func RunSubTests(t *testing.T, x interface{})

RunSubTests runs all "Test___" functions that are methods of x as subtests of the current test. If x contains methods "Setup(*testing.T)" or "Teardown(*testing.T)", those are run before or after each of the test functions, respectively.

For example usage, see example_test.go. Run it using:

$ go test -v -run TestExample .

To run a specific test/subtest:

$ go test -v -run 'TestExample/^Something$' .

Types

type Tester

type Tester struct{}

Tester is an implementation of the x interface parameter to grpctest.RunSubTests with default Setup and Teardown behavior. Setup updates the tlogger and Teardown performs a leak check. Embed in a struct with tests defined to use.

func (Tester) Setup

func (Tester) Setup(t *testing.T)

Setup updates the tlogger.

func (Tester) Teardown

func (Tester) Teardown(t *testing.T)

Teardown performs a leak check.

Source Files

grpctest.go tlogger.go

Version
v1.56.1
Published
Jun 21, 2023
Platform
linux/amd64
Imports
15 packages
Last checked
1 minute ago

Tools for package owners.