Documentation
¶
Overview ¶
Package testing provides helpers for organizing unit, integration, and end-to-end tests.
Index ¶
- type EndToEndTest
- type IntegrationTest
- type TableDrivenTest
- type TestData
- type TestSuite
- func (ts *TestSuite) AddE2ETest(name, description string, setup, teardown func() error, ...)
- func (ts *TestSuite) AddIntegrationTest(name, description string, setup, teardown func() error, ...)
- func (ts *TestSuite) AddUnitTest(name, description string, testFunc func(t *testing.T))
- func (ts *TestSuite) RunAllTests(t *testing.T)
- func (ts *TestSuite) RunE2ETests(t *testing.T)
- func (ts *TestSuite) RunIntegrationTests(t *testing.T)
- func (ts *TestSuite) RunUnitTests(t *testing.T)
- type UnitTest
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 TestSuite ¶
type TestSuite struct {
Unit map[string]UnitTest
Integration map[string]IntegrationTest
E2E map[string]EndToEndTest
}
TestSuite organizes tests by functionality
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 ¶
AddUnitTest adds a unit test to the suite
func (*TestSuite) RunAllTests ¶
RunAllTests runs all tests in the suite
func (*TestSuite) RunE2ETests ¶
RunE2ETests runs all end-to-end tests in the suite
func (*TestSuite) RunIntegrationTests ¶
RunIntegrationTests runs all integration tests in the suite
func (*TestSuite) RunUnitTests ¶
RunUnitTests runs all unit tests in the suite