disttest

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package disttest provides utilities for recording and reporting distributed test results. It includes functions to wrap test cases, record failures, and write results to a JSON file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail added in v0.0.7

func Fail(t *testing.T, format string, args ...interface{})

Fail records a failure reason for the current test and fails the test. It should be used instead of t.Fatal or t.Errorf to ensure the failure reason is recorded.

func Wrap

func Wrap(t *testing.T, fn func(t *testing.T))

Wrap should be used around each test body: It records the test result and duration. It also recovers from panics and records them as test failures.

func Write

func Write(file string) error

Write writes the recorded test results to the specified file in JSON format.

Types

type ResultType

type ResultType string
const (
	TypeSuccess ResultType = "success"
	TypeFailure ResultType = "failure"
	TypePanic   ResultType = "panic"
)

type TestResult

type TestResult struct {
	Type       ResultType `json:"type"`
	Name       string     `json:"name"`
	DurationMs int64      `json:"duration_ms"`
	Message    string     `json:"message,omitempty"`
	Panic      string     `json:"panic,omitempty"`
}

TestResult represents the result of a single test execution.

Jump to

Keyboard shortcuts

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