The v2 our tests wanted
A set of go packages that provide tools for testifying (verifying) that your code behaves as you intended.
This is the go-openapi fork of the great testify package.
Note
This is the home of github.com/go-openapi/testify/v2, an active, opinionated fork of github.com/stretchr/testify.
- 95% compatible with
stretchr/testify— if you already use it, our migration tool automates the switch - Actively maintained: regular fixes and evolutions, many PRs proposed upstream are already in
- Zero external dependencies — you import what you need, with opt-in modules for extras (e.g. YAML, colorized output)
- Modernized codebase targeting go1.24+
- Go routine leak detection built in: zero-setup, no false positives, works with parallel tests (unlike
go.uber.org/goleak) - File descriptor leak detection (linux-only)
- Type-safe assertions with generics (see a basic example) — migration to generics can be automated too. Read the full story
- Safe async assertions, extended JSON & YAML assertions
- Coming in
v2.5.0: non-flaky async assertions usingsynctest, and internal tools exposed as standalone modules (spew, unified diff, goleak) - We take documentation seriously: searchable doc site with testable examples and a complete tutorial, plus detailed godoc for every assertion
- You need the
mockpackage — we removed it and won't bring it back. For suites, we're open to discussion about a redesigned approach - Your project must support Go versions older than 1.24
- You rely on
testifylintor other tooling that expects thestretchr/testifyimport path - You need 100% API compatibility — we're at 95%, and the remaining 5% are intentional removals
- 2025-12-19 : new community chat on discord
- a new discord community channel is available to be notified of changes and support users
- our venerable Slack channel remains open, and will be eventually discontinued on 2026-03-31
You may join the discord community by clicking the invite link on the discord badge (also above).
Design and exploration phase completed. The published API is now stable: moving forward, API changes will remain backward-compatible with v2.4.0.
Feedback, contributions and proposals are welcome.
Recent news
✅ Stabibilized API
✅ Migration tool
✅ Fully refactored how assertions are generated and documented. Opt-in features with their dependencies.
Fixes
✅ Fixed hangs & panics when using
spew. Fuzzedspew. Fixed deterministic order of keys in diff.✅ Fixed go routine leaks with
EventuallyWithand co.✅ Fixed wrong logic with
IsNonIncreasing,InNonDecreasing✅ Fixed edge cases with
InDelta,InEpsilon✅ Fixed edge cases with
EqualValuesAdditions
✅ Introduced generics: ~ 40 new type-safe assertions with generic types (doc: added usage guide, examples and benchmark)
✅ Added
Kind&NotKind,Consistently,NoGoRoutineLeak,NoFileDescriptorLeak✅ Added opt-in support for colorized output
See also our ROADMAP.
Import this library in your project like so.
go get github.com/go-openapi/testify/v2... and start writing tests. Look at our examples.
testify simplifies your test assertions like so.
import (
"testing"
)
...
const expected = "expected result"
result := printImports(input)
if result != expected {
t.Errorf(
"Expected: %s. Got: %s", expected, result,
)
return
}Becomes:
import (
"testing"
"github.com/go-openapi/testify/v2/require"
)
...
const expected = "expected result"
require.Equalf(t,
expected, printImports(input), "Expected: %s. Got: %s",
expected, result,
)This fork now fully replaces the original project for all go-openapi projects, thus reducing their dependencies footprint.
Go-swagger has also adopted it. Now the work is to generalize the use of generics (leveraging our migration tool).
Features might be added to support our main use cases there.
See https://github.com/go-openapi/testify/releases
SPDX-FileCopyrightText: Copyright 2025 go-swagger maintainers
This library ships under the SPDX-License-Identifier: Apache-2.0.
See the license NOTICE, which recalls the licensing terms of all the pieces of software distributed with this fork, including internalized libraries.
Maintainers can cut a new release by either:
- running this workflow (recommended)
- or :
- preparing go.mod files with the next tag, merge
- pushing a semver tag
- signed tags are preferred
- The tag message is prepended to release notes