Zero-dependency testing toolkit for Go. 72+ assertion functions, golden files, mocks, and a spy for testing your own test helpers.
When an assertion fails, you see exactly where and why:
type Order struct {
ID int
Email string
Total float64
}
want := Order{ID: 1, Email: "alice@example.com", Total: 9.99}
have := Order{ID: 1, Email: "alice@wrong.com", Total: 9.99}
assert.Equal(t, want, have)
// Test log:
//
// expected values to be equal:
// trail: Order.Email
// want: "alice@example.com"
// have: "alice@wrong.com"Trails work through nested structs, maps, slices, and pointers. Custom
checkers and dumpers can target any type or trail. The check package returns
plain error instead of calling t.Fatal, so checks compose naturally into
your own assertion functions. The tester package provides a Spy that
records calls to t.Error/t.Fatal, letting you write real tests for
your own test helpers.
The library supports both global customization (via RegisterTypeChecker,
RegisterTypeDumper, and package-level variables) and fine-grained per-call
control via options.
The toolkit follows a deliberate layered architecture:
assert— the user-facing layer. Thin wrappers that callt.Errorort.Fatalon failure.check— pure functions that returnerror(or*notice.Notice). Composable, no test dependency, ideal for building your own helpers.notice— rich, structured message builder with trails, rows, metadata, and join support for detailed diagnostics.
This separation lets the same powerful checks be used both directly in tests and inside custom assertion functions without pulling in testing concerns.
The customization model supports both global defaults (via
RegisterTypeChecker / RegisterTypeDumper and package-level variables)
and fine-grained per-use control through options passed to individual
checks and assertions (see [check.DefaultOptions] and the With* functions
in check and dump).
go get github.com/ctx42/testingAll packages include rich package-level overviews, extensive
cross-references, and (where appropriate) executable examples_test.go
files whose output is wired into the READMEs.
Certain packages expose intentionally public surface for advanced or cross-project use:
pkg/testcases— battle-tested test values for writing and testing custom assertions/helpers (see its package documentation).pkg/kittop-level helpers such asAddGlobalCleanup/RunGlobalCleanups— forTestMain-style post-test coordination (see godoc for warnings).
Packages used directly in test files.
- assert — 72+ assertion functions with rich trails and custom checkers.
- check — composable checks that return
error(or*notice.Notice), designed for both direct use and custom helpers. - goldy — golden file testing with testable
public surface via
tester.T. - kit — curated collection of focused test helpers (I/O buffers, deterministic clocks, reflection utilities, plus a few top-level helpers).
- mock — primitives for writing interface mocks (expectations, matchers, call recording).
- mocker — code generator for interface mocks
that integrate with the
mockpackage. - must — helpers that panic on error for concise test setup and assertions.
Foundational packages for building custom checks, assertions, and helpers.
- dump — configurable renderer of any value to a human-readable string (used throughout for diagnostics).
- notice — builder for rich, structured assertion messages with trails, rows, metadata, and join support.
- tester —
Spyimplementation oftester.Tfor writing real tests of your own test helpers.
Each package has its own README.md with detailed usage and most
include an examples_test.go file with runnable, documented examples.
