Testify v2
Info
This is the home of github.com/go-openapi/testify/v2, an active, opinionated fork of github.com/stretchr/testify.
Testify v2 - 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.
Status
Design and exploration phase completed. The published API is now stable: moving forward, API changes will remain backward-compatible with v2.4.0.
See our ROADMAP.
Motivation
See why we wanted a v2.
Getting started
Import this library in your project like so.
… and start writing tests. Look at our examples.
Basic usage
testify simplifies your test assertions like so.
- Standard library
- testify
Usage with generics
Assertion functions that support go generic types are suffixed with T (for “Type safety”).
A formatted variant suffixed with Tf is also exposed.
Build with go1.27 or newer and every generic assertion is also a method of the Assertions type:
a.EqualT(expected, result) alongside require.EqualT(t, expected, result). go1.27 is the first
release that accepts type parameters on methods; on go1.25 and go1.26 those methods are excluded by
a //go:build go1.27 guard, and the package-level functions below are the only form available.
- EqualT
- InDeltaT
Licensing
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.
We’d like to give credit and pay a big and loud thank you to the people who wrote these amazing pieces of software. We maintain their original work here and continue improving it.
- Mat Ryer, Tyler Bunnell and the
stretchr/testifycontributors - who made this new project possible - thank you to the maintainers of that library, @ccoveille, @dolmen for their feedback and advice
- Dave Collins dave@davec.name who wrote the spew library
- Patrick Mezard who wrote the difflib library - originally a go port from python’s difflib
Also special thanks to:
- Gregory Petrosyan (@flyingmutant) - we use his amazing “rapid” library for our integration tests, with property-based testing
- the authors and maintainers of github.com/yaml/go-yaml, which we rely on for our YAML work
Contributing
Feel free to submit issues, fork the repository and send pull requests!
Info
Code generation is used. Run go generate ./... to update generated files.
See also our CONTRIBUTING guidelines.
See Also
Getting Started:
- Usage Guide - API conventions and how to navigate the documentation
- Tutorial - Best practices and patterns for writing great tests
- Examples - Practical code examples for common testing scenarios
Advanced Topics:
- Generics Guide - Type-safe assertions with generic functions
- Migration Guide - Migrating from stretchr/testify v1
- Changes from v1 - All changes and improvements in v2
- Benchmarks - Performance improvements in v2
Reference:
- API Reference - Complete assertion catalog organized by domain
Index Of Assertion Domains.
Find the assertion function you need for your data.
- Guides, examples and tutorials.
- Project roadmap, contributing guidelines and maintainer’s guide.