xfail

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

xfail

Go Reference

Go package providing a testing helper for expected test failures.

XFail returns a new testing.TB instance that expects the test to fail for the given reason. At the end of the test, if it was marked as failed using non-fatal methods Fail, Error, or Errorf, it will pass instead. If it wasn't marked as failed, it will fail so that the XFail call can be removed. Fatal methods FailNow, Fatal, or Fatalf will skip the rest of the test instead.

func TestParseDuration(tt *testing.T) {
	t := XFail(tt, "https://github.com/golang/go/issues/67076")

	if _, err := time.ParseDuration("3.336e-6s"); err != nil {
		t.Fatal(err)
	}
}

License

Copyright 2021 FerretDB Inc. Licensed under Apache License v2.0.

Documentation

Overview

Package xfail provides a testing helper for expected test failures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func XFail

func XFail(tb testing.TB, reason string) testing.TB

XFail returns a new testing.TB instance that expects the test to fail for the given reason.

At the end of the test, if it was marked as failed using non-fatal methods Fail, Error, or Errorf, it will pass instead. If it wasn't marked as failed, it will fail so that the XFail call can be removed. Fatal methods FailNow, Fatal, or Fatalf will skip the rest of the test instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL