testingx

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package testingx contains functions and data to facilitate testing using the testing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTests

func RunTests[T, U any](ctx context.Context, t *testing.T, cases []TestCase[T, U], testFn TestFunc[T, U])

RunTests runs all provided test cases using the given test function.

Types

type TestCase

type TestCase[T, U any] struct {
	Name      string
	Input     T
	SetupFn   func(context.Context) context.Context
	CheckFn   func(context.Context, *testing.T, TestResult[U])
	CleanupFn func(context.Context)
}

TestCase represents a named test case, combining the input with a function for checking the observed result.

type TestFunc

type TestFunc[T, U any] func(context.Context, T) TestResult[U]

TestFunc represents a function that consumes a test input and returns a result.

type TestResult

type TestResult[U any] struct {
	Success U
	Err     error
}

TestResult represents the result of a test.

Jump to

Keyboard shortcuts

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