testingx

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package testingx provides set of utilities for tests and runnable examples.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertTB

type AssertTB interface {
	Helper()
	Errorf(format string, args ...interface{})
}

AssertTB is a subinterface of testing.TB that fulfills the needs of assert package from testify library, but also includes the Helper method. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.

type E

type E struct {
	Verbose bool
}

E is emulating a testing.TB for runnable examples. It is useful to show usage of the library elements dedicated to tests, how they can be used. Unfortunately, testing.TB cannot be implemented because it has a private method on the interface. This is why it's preferable to use one of testingx or own declared interfaces as argument types instead.

WARNING: This struct is still under development, and still some parts are not implemented completely.

func (*E) Chdir

func (e *E) Chdir(dir string)

Chdir is a testing.TB Chdir method implementation for runnable examples.

func (*E) Cleanup

func (e *E) Cleanup(f func())

Cleanup is a testing.TB Cleanup method implementation for runnable examples.

func (*E) Context

func (e *E) Context() context.Context

Context is a testing.TB Context method implementation for runnable examples.

func (*E) Error

func (e *E) Error(args ...any)

Error is a testing.TB Error method implementation for runnable examples. It writes the error message with "ERROR:" prefix.

func (*E) Errorf

func (e *E) Errorf(format string, args ...interface{})

Errorf is a testing.TB Errorf method implementation for runnable examples. It writes the error message with "ERROR:" prefix.

func (*E) Fail

func (e *E) Fail()

Fail is a testing.TB Fail method implementation for runnable examples.

func (*E) FailNow

func (e *E) FailNow()

FailNow is a testing.TB FailNow method implementation for runnable examples.

func (*E) Failed

func (e *E) Failed() bool

Failed is a testing.TB Failed method implementation for runnable examples.

func (*E) Fatal

func (e *E) Fatal(args ...any)

Fatal is a testing.TB Fatal method implementation for runnable examples.

func (*E) Fatalf

func (e *E) Fatalf(format string, args ...any)

Fatalf is a testing.TB Fatalf method implementation for runnable examples.

func (*E) Helper

func (e *E) Helper()

Helper is a testing.TB Helper method implementation for runnable examples.

func (*E) Log

func (e *E) Log(args ...any)

Log is a testing.TB Log method implementation for runnable examples.

func (*E) Logf

func (e *E) Logf(format string, args ...any)

Logf is a testing.TB Logf method implementation for runnable examples.

func (*E) Name

func (e *E) Name() string

Name is a testing.TB Name method implementation for runnable examples.

func (*E) Setenv

func (e *E) Setenv(key, value string)

Setenv is a testing.TB Setenv method implementation for runnable examples.

func (*E) Skip

func (e *E) Skip(args ...any)

Skip is a testing.TB Skip method implementation for runnable examples.

func (*E) SkipNow

func (e *E) SkipNow()

SkipNow is a testing.TB SkipNow method implementation for runnable examples.

func (*E) Skipf

func (e *E) Skipf(format string, args ...any)

Skipf is a testing.TB Skipf method implementation for runnable examples.

func (*E) Skipped

func (e *E) Skipped() bool

Skipped is a testing.TB Skipped method implementation for runnable examples.

func (*E) TempDir

func (e *E) TempDir() string

TempDir is a testing.TB TempDir method implementation for runnable examples.

type PrintingTBE

type PrintingTBE interface {
	Helper()
	Errorf(format string, args ...interface{})
	Error(args ...any)
	Log(args ...any)
	Logf(format string, args ...any)
}

PrintingTBE is a subinterface of testing.TB that provides the printing methods of testing.TB (Log, Logf, Error, Errorf) and the Helper method.

type RequireTB

type RequireTB interface {
	AssertTB
	FailNow()
}

RequireTB is a subinterface of testing.TB that fulfills the needs of require package from testify library, but also includes the FailNow method. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.

type TB

type TB interface {
	Cleanup(func())
	Error(args ...any)
	Errorf(format string, args ...any)
	Fail()
	FailNow()
	Failed() bool
	Fatal(args ...any)
	Fatalf(format string, args ...any)
	Helper()
	Log(args ...any)
	Logf(format string, args ...any)
	Name() string
	Setenv(key, value string)
	Chdir(dir string)
	Skip(args ...any)
	SkipNow()
	Skipf(format string, args ...any)
	Skipped() bool
	TempDir() string
	Context() context.Context
}

TB is a copy of testing.TB interface, that also allows for implementing it. This package also provides an implementation of this interface, called testingx.E, that can be used in runnable examples.

type TBE

type TBE interface {
	PrintingTBE
	FailNow()
}

TBE is a subinterface that gives reasonable minimum set of methods from testing.TB, that can be used in tests and runnable examples.

Jump to

Keyboard shortcuts

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