---
title: "Testify v2"
type: home
description: 'The v2 our tests wanted'
weight: 1
---

{{% notice info %}}
This is the home of `github.com/go-openapi/testify/v2`, an active, opinionated fork of `github.com/stretchr/testify`.
{{% /notice %}}

## 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](https://github.com/stretchr/testify) package.

### Status

{{% button href="https://github.com/go-openapi/testify/fork" hint="fork me on github" style=primary icon=code-fork %}}Fork me{{% /button %}}
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](./project/maintainers/ROADMAP.md).

### Motivation

See [why we wanted a v2](./project/MOTIVATION.md).

### Getting started

Import this library in your project like so.

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

... and start writing tests. Look at our [examples][doc-examples].

### Basic usage

`testify` simplifies your test assertions like so.

{{< cards >}}
{{% card title="Standard library" %}}
```go
import (
        "testing"
    )
    ...
    
    const expected = "expected result"

	  result := printImports(input)
	  if result != expected {
		  t.Errorf(
        "Expected: %s. Got: %s",
        expected, result, 
      )

      return
	  }
```
{{% /card %}}

{{% card title="testify" %}}
```go
import (
        "testing"

        "github.com/go-openapi/testify/v2/require"
    )
    ...

    const expected = "expected result"

	  result := printImports(input)
	  require.Equalf(t, expected, result,
        "Expected: %s. Got: %s", expected, result, 
    )
```
{{% /card %}}
{{< /cards >}}

### 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.

{{< cards >}}
{{% card title="EqualT" %}}
```go
import (
        "testing"

        "github.com/go-openapi/testify/v2/require"
    )
    ...
    
    const expected = "Hello World"
    var input := "World"

	result := someRamblingTextGeneration(input)
    require.EqualT(t, expected, result)
```
{{% /card %}}
{{% card title="InDeltaT" %}}
```go
import (
        "testing"

        "github.com/go-openapi/testify/v2/require"
    )
    ...
    
    const (
        expected = 1.00
        delta = 1E-6
    )
    var input = 1.01

	result := someComplexComputation(input)
    require.InDeltaT(t, expected, input, delta)
```
{{% /card %}}
{{< /cards >}}

## Licensing

`SPDX-FileCopyrightText: Copyright 2025 go-swagger maintainers`

This library ships under the [SPDX-License-Identifier: Apache-2.0](./project/LICENSE.md).

See the license [NOTICE](./project/NOTICE.md), 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/testify` contributors - 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!

{{% notice style="primary" title="Info" icon="info" %}}
Code generation is used. Run `go generate ./...` to update generated files.
{{% /notice %}}

See also our [CONTRIBUTING guidelines](./project/contributing/CONTRIBUTING.md).

---

## See Also

**Getting Started:**
- [Usage Guide](./usage/USAGE.md) - API conventions and how to navigate the documentation
- [Tutorial](./usage/TUTORIAL.md) - Best practices and patterns for writing great tests
- [Examples](./usage/EXAMPLES.md) - Practical code examples for common testing scenarios

**Advanced Topics:**
- [Generics Guide](./usage/GENERICS.md) - Type-safe assertions with generic functions
- [Migration Guide](./usage/MIGRATION.md) - Migrating from stretchr/testify v1
- [Changes from v1](./usage/CHANGES.md) - All changes and improvements in v2
- [Benchmarks](./project/maintainers/BENCHMARKS.md) - Performance improvements in v2

**Reference:**
- [API Reference](./api/_index.md) - Complete assertion catalog organized by domain

---

{{< children type="card" description="true" >}}

[doc-examples]: ./usage/EXAMPLES.md
