xtesting

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package xtesting contains utilities for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Benchmark

func Benchmark(
	b *testing.B,
	setup func(context.Context) error,
	pre func(context.Context) error,
	fn func(context.Context) error,
	post func(context.Context) error,
)

Benchmark benchmarks fn.

It calls the setup function once before the first iteration of the benchmark.

The pre and post functions before and after each iteration of the benchmark, respectively.

Only the time spent in fn is measured.

func ContextForCleanup

func ContextForCleanup(t testing.TB) context.Context

ContextForCleanup returns a context with a short timeout that can be used to cleanup after a test ends.

It can be called at any time during the test (including within a cleanup function). The returned context will be cancelled 3 seconds after the test ends.

func SequentialName

func SequentialName(prefix string) string

SequentialName returns a unique name with the given prefix.

func UniqueName

func UniqueName(prefix string) string

UniqueName returns a unique name with the given prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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