Skip to content
/ testify Public
forked from go-openapi/testify

A toolkit with common assertions and mocks that plays nicely with the standard library

License

Notifications You must be signed in to change notification settings

fredbi/testify

 
 

Testify/v2

Tests Coverage CI vuln scan CodeQL

Release Go Report Card CodeFactor Grade License

Doc GoDoc Discord Channel go version Top language Commits since latest release


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:

Announcements

  • 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). Discord Channel

Or join our Slack channel: Slack Channelslack-badge

Status

Design and exploration phase. Feedback, contributions and proposals are welcome.

Recent news

✅ Fully refactored how assertions are generated and documented.

✅ Fixed hangs & panics when using spew. Fuzzed spew.

✅ Fixed go routine leaks with EventuallyWithT and co.

✅ Added Kind & NotKind

✅ Fix deterministic order of keys in diff

✅ Fixed edge cases with InDelta, InEpsilon

✅ Fixed edge cases with EqualValues

✅ Fixed wrong logic with IsNonIncreasing, InNonDecreasing

✅ Added opt-in support for colorized output

✅ Introduced generics: 38 new type-safe assertions with generic types (doc: added usage guide, examples and benchmark)

See also our ROADMAP.

Getting started

Import this library in your project like so.

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.

    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, 
    )

Usage at go-openapi and go-swagger

This fork now fully replaces the original project for all go-openapi projects, thus reducing their dependencies footprint.

Go-swagger will be adapted over Q1 2026.

Features will probably be added to support our main use cases there.

Change log

See https://github.com/go-openapi/testify/releases

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.

Other documentation

Cutting a new release

Maintainers can cut a new release by either:

  • running this workflow (recommended)
  • or :
    1. preparing go.mod files with the next tag, merge
    2. pushing a semver tag
    • signed tags are preferred
    • The tag message is prepended to release notes

About

A toolkit with common assertions and mocks that plays nicely with the standard library

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 96.4%
  • Go Template 3.1%
  • Other 0.5%