test

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package test provides structured test reporting for AI consumption.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTestSID

func GenerateTestSID(suite, name string) string

GenerateTestSID generates a stable SID for a test case

Types

type Case

type Case struct {
	SID        string   `json:"sid"`
	Suite      string   `json:"suite"`
	Name       string   `json:"name"`
	Status     string   `json:"status"` // passed|failed|errored|skipped
	TimeMs     int64    `json:"time_ms"`
	TraceSlice []string `json:"trace_slice,omitempty"` // SIDs for failure navigation
	Error      any      `json:"error,omitempty"`       // errors.Encoded
}

Case represents a single test case result

type Counts

type Counts struct {
	Passed  int `json:"passed"`
	Failed  int `json:"failed"`
	Errored int `json:"errored"`
	Skipped int `json:"skipped"`
	Total   int `json:"total"`
}

Counts provides test result statistics

type Platform

type Platform struct {
	GoVersion string `json:"go_version"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
	Timestamp string `json:"timestamp"`
}

Platform captures environment information for reproducibility

type Report

type Report struct {
	Schema        string   `json:"schema"`
	RunID         string   `json:"run_id"`
	Seed          *int     `json:"seed,omitempty"`
	EnvLockDigest string   `json:"env_lock_digest,omitempty"`
	DurationMs    int64    `json:"duration_ms"`
	Counts        Counts   `json:"counts"`
	Cases         []Case   `json:"cases"`
	Platform      Platform `json:"platform"`
}

Report represents a complete test run report

func EmptyReport

func EmptyReport() *Report

EmptyReport returns a valid empty report (for 0 tests)

func NewReport

func NewReport() *Report

NewReport creates a new test report

func (*Report) AddCase

func (r *Report) AddCase(c Case)

AddCase adds a test case to the report

func (*Report) Finalize

func (r *Report) Finalize(startTime time.Time)

Finalize sorts cases and sets final timing

func (*Report) SetEnvLockDigest

func (r *Report) SetEnvLockDigest(digest string)

SetEnvLockDigest sets the environment lock file digest

func (*Report) SetSeed

func (r *Report) SetSeed(seed int)

SetSeed sets the random seed if deterministic testing was used

func (*Report) ToJSON

func (r *Report) ToJSON() ([]byte, error)

ToJSON converts the report to deterministic JSON

type TestRunner

type TestRunner struct {
	// contains filtered or unexported fields
}

TestRunner provides methods for running and reporting tests

func NewRunner

func NewRunner() *TestRunner

NewRunner creates a new test runner

func (*TestRunner) GetReport

func (tr *TestRunner) GetReport() *Report

GetReport finalizes and returns the test report

func (*TestRunner) RunTest

func (tr *TestRunner) RunTest(suite, name string, testFunc func() error)

RunTest executes a test and records the result

func (*TestRunner) Skip

func (tr *TestRunner) Skip(suite, name string, reason string)

Skip marks a test as skipped

Jump to

Keyboard shortcuts

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