package tdtest
import "cuelang.org/go/internal/tdtest"
Package tdtest provides support for table-driven testing.
Features include automatically updating of test values, automatic error message generation, and singling out single tests to run.
Auto updating fields is only supported for fields that are scalar types: string, bool, int*, and uint*. If the field is a string, the "actual" value may be any Go value that can meaningfully be printed with fmt.Sprint.
Index ¶
Variables ¶
var UpdateTests = false
UpdateTests defines whether tests should be updated by default. This can be overridden on an individual basis using T.Update.
Functions ¶
func Run ¶
Run runs the given function for each (selected) element in the table. TC must be a struct type. If that has a string field named "name", that value will be used to name the associated subtest.
Types ¶
type T ¶
T is a single test case representing an element in a table. It embeds *testing.T, so all functions of testing.T are available.
func (*T) Equal ¶
Equal compares two fields.
For auto updating to work, field must reference a field in the test case directly.
func (*T) Select ¶
Select species which tests to run. The test may be an int, in which case it selects the table entry to run, or a string, which is matched against the last path of the test. An empty list runs all tests.
func (*T) Update ¶
Update specifies whether to update the Go structs in case of discrepancies. It overrides the default setting.
Source Files ¶
tdtest.go update.go
- Version
- v0.11.0-rc.1
- Published
- Nov 13, 2024
- Platform
- darwin/amd64
- Imports
- 15 packages
- Last checked
- 48 minutes ago –
Tools for package owners.