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.
Main features:
- zero external dependencies
- opt-in dependencies for extra features (e.g. asserting YAML, colorized output)
- assertions using generic types (see a basic example). Read the fully story with generics
- searchable documentation
- 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