
assert
assert is a tiny, zero-dependency assertion library for Go tests.
The project focuses on a single goal: provide the most useful test assertions with no framework bloat and no external dependency tree. If you like the convenience of assertion helpers but want to avoid alternatives like testify/assert, this library is designed for you.
It keeps the API intentionally small and practical, with helpers such as:
- boolean assertions
- error matching (
ErrorIs)
- nil / not-nil checks
- panic assertions
- timeout-based test guards
In short: a lean assertion toolkit that stays close to the standard testing package and gets out of your way.
One package, both assert and require semantics
Unlike ecosystems where you import separate packages for assert and require, this library uses one API and lets you configure failure behavior via New(failFunc ...).
- Use a non-fatal fail function (for example
t.Errorf) when you want assert-like behavior.
- Use a fatal fail function (for example
t.FailNow) when you want require-like behavior.
requireLike := assert.New()
assertLike := assert.New(func(t *testing.T, format string, params ...any) {
t.Helper()
t.Errorf(format, params...)
})
This gives you the same practical flexibility while keeping dependencies and API surface minimal.