📖 3 min read (~ 500 words).

Testify v2

Go testing assertions for the rest of us

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 that your code behaves as you intended.

This is the go-openapi fork of the great testify package.

Status

Fork me Design and exploration phase. Contributions and proposals are welcome.

Motivation

From the maintainers of testify, it looks like a v2 will eventually be released, but they’ll do it at their own pace.

We like all the principles they put forward to build this v2. See discussion about v2

However, at go-openapi we would like to address the well-known issues in testify with different priorities.

With this fork, we want to:

  1. remove all external dependencies.
  2. make it easy to maintain and extend.
  3. pare down some of the chrome that has been added over the years.
Extended hand

We hope that this endeavor will help the original project with a live-drill of what a v2 could look like. Hopefully, some of our ideas here will eventually percolate back into the original project.

We are always happy to discuss with people who face the same problems as we do: avoid breaking changes, APIs that became bloated over a decade or so, uncontrolled dependencies, difficult choices when it comes to introduce breaking changes, conflicting demands from users etc.

More about our motivations in the project’s README.

Getting started

To use this package in your projects:

    go get github.com/go-openapi/testify/v2

… and start writing tests. Look at our examples.

Basic usage

testify simplifies your test assertions like so.

  • Standard library
        import (
            "testing"
        )
        ...
        
        const expected = "expected result"
    
    	result := printImports(input)
    	if result != expected {
    		t.Errorf(
                "Expected: %s. Got: %s",
                expected, result, 
            )
    
            return
    	}
  • testify
        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, 
        )

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.

Contributing

Please feel free to submit issues, fork the repository and send pull requests!

When submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it.

Info

Code generation is used. Run go generate ./... to update generated files.

See also the CONTRIBUTING guidelines.