testing

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package testing provides helpers for organizing unit, integration, and end-to-end tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EndToEndTest

type EndToEndTest struct {
	Name        string
	Description string
	Setup       func() error
	Teardown    func() error
	TestFunc    func(t *testing.T)
}

EndToEndTest represents an end-to-end test

type IntegrationTest

type IntegrationTest struct {
	Name        string
	Description string
	Setup       func() error
	Teardown    func() error
	TestFunc    func(t *testing.T)
}

IntegrationTest represents an integration test

type TableDrivenTest

type TableDrivenTest struct {
	Name     string
	Tests    []TestData
	TestFunc func(t *testing.T, test TestData)
}

TableDrivenTest provides a consistent pattern for table-driven tests

func NewTableDrivenTest

func NewTableDrivenTest(
	name string,
	tests []TestData,
	testFunc func(t *testing.T, test TestData),
) *TableDrivenTest

NewTableDrivenTest creates a new table-driven test

func (*TableDrivenTest) Run

func (tdt *TableDrivenTest) Run(t *testing.T)

Run executes the table-driven test

type TestData

type TestData struct {
	Name     string
	Input    any
	Expected any
	Error    error
}

TestData represents a generic test case structure

type TestSuite

type TestSuite struct {
	Unit        map[string]UnitTest
	Integration map[string]IntegrationTest
	E2E         map[string]EndToEndTest
}

TestSuite organizes tests by functionality

func NewTestSuite

func NewTestSuite() *TestSuite

NewTestSuite creates a new test suite

func (*TestSuite) AddE2ETest

func (ts *TestSuite) AddE2ETest(
	name, description string,
	setup, teardown func() error,
	testFunc func(t *testing.T),
)

AddE2ETest adds an end-to-end test to the suite

func (*TestSuite) AddIntegrationTest

func (ts *TestSuite) AddIntegrationTest(
	name, description string,
	setup, teardown func() error,
	testFunc func(t *testing.T),
)

AddIntegrationTest adds an integration test to the suite

func (*TestSuite) AddUnitTest

func (ts *TestSuite) AddUnitTest(name, description string, testFunc func(t *testing.T))

AddUnitTest adds a unit test to the suite

func (*TestSuite) RunAllTests

func (ts *TestSuite) RunAllTests(t *testing.T)

RunAllTests runs all tests in the suite

func (*TestSuite) RunE2ETests

func (ts *TestSuite) RunE2ETests(t *testing.T)

RunE2ETests runs all end-to-end tests in the suite

func (*TestSuite) RunIntegrationTests

func (ts *TestSuite) RunIntegrationTests(t *testing.T)

RunIntegrationTests runs all integration tests in the suite

func (*TestSuite) RunUnitTests

func (ts *TestSuite) RunUnitTests(t *testing.T)

RunUnitTests runs all unit tests in the suite

type UnitTest

type UnitTest struct {
	Name        string
	Description string
	TestFunc    func(t *testing.T)
}

UnitTest represents a unit test

Jump to

Keyboard shortcuts

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