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 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.
go get github.com/ctx42/testingPackages used in test files.
- Package assert — 72+ assertion functions.
- Package check — composable equality checks; returns
error, not panics. - Package goldy — golden file testing.
- Package kit — test helpers (buffers, clocks, cleanup).
- Package mock — primitives for writing interface mocks.
- Package mocker — interface mock code generator.
- Package must — helpers that panic on error.
Packages for building custom checks, assertions, and helpers.
- Package dump — configurable renderer of any type to a string.
- Package notice — formatted assertion message builder.
- Package tester —
Spyfor testing test helpers.
Each package has its own README.md and most include an examples_test.go
file with runnable examples.
