package testutil

Import Path
	github.com/efficientgo/core/testutil (on go.dev)

Dependency Relation
	imports 10 packages, and imported by one package

Involved Source Files Package testutil is a minimal testing utility with only few functions like `Assert`, `Ok`, `NotOk` for errors and `Equals`. It also provides TB ("TestOrBench") utility for union of testing and benchmarks. testorbench.go testutil.go
Package-Level Type Names (only one)
/* sort by: | */
TB represents union of test and benchmark. This allows the same test suite to be run by both benchmark and test, helping to reuse more code. The reason is that usually benchmarks are not being run on CI, especially for short tests, so you need to recreate usually similar tests for `Test<Name>(t *testing.T)` methods. Example of usage is presented here: func TestTestOrBench(t *testing.T) { tb := NewTB(t) tb.Run("1", func(tb TB) { testorbenchComplexTest(tb) }) tb.Run("2", func(tb TB) { testorbenchComplexTest(tb) }) } func BenchmarkTestOrBench(b *testing.B) { tb := NewTB(t) tb.Run("1", func(tb TB) { testorbenchComplexTest(tb) }) tb.Run("2", func(tb TB) { testorbenchComplexTest(tb) }) } ( TB) Attr(key, value string) ( TB) Chdir(dir string) ( TB) Cleanup(func()) ( TB) Context() context.Context ( TB) Error(args ...any) ( TB) Errorf(format string, args ...any) ( TB) Fail() ( TB) FailNow() ( TB) Failed() bool ( TB) Fatal(args ...any) ( TB) Fatalf(format string, args ...any) ( TB) Helper() ( TB) IsBenchmark() bool ( TB) Log(args ...any) ( TB) Logf(format string, args ...any) ( TB) N() int ( TB) Name() string ( TB) Output() io.Writer ( TB) ResetTimer() ( TB) Run(name string, f func(t TB)) bool ( TB) SetBytes(n int64) ( TB) Setenv(key, value string) ( TB) Skip(args ...any) ( TB) SkipNow() ( TB) Skipf(format string, args ...any) ( TB) Skipped() bool ( TB) TempDir() string TB : github.com/apache/arrow-go/v18/arrow/memory.TestingT TB : github.com/polarsignals/frostdb/query/logicalplan.Named TB : github.com/stretchr/testify/assert.TestingT TB : github.com/stretchr/testify/require.TestingT TB : testing.TB func NewTB(t testing.TB) TB
Package-Level Functions (total 8)
Assert fails the test if the condition is false.
ContainsStringSlice fails the test if needle is not contained within haystack, if haystack or needle is an empty slice, or if needle is longer than haystack.
Equals fails the test if exp is not equal to act.
FaultOrPanicToErr returns error if panic of fault was triggered during execution of function.
NewTB creates tb from testing.TB.
NotOk fails the test if an err is nil.
Ok fails the test if an err is not nil.
WithGoCmp allows specifying options and using https://github.com/google/go-cmp for equality comparisons. The compatibility guarantee of this function's arguments are the same as go-cmp (no guarantee due to v0.x).