Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixtureTasks ¶
func FixtureTasks() Task
FixtureTasks creates tasks for building and managing test fixtures. It looks for Makefiles in test-fixtures and testdata directories and runs them. Hooks into "unit" to build fixtures before tests run.
Created tasks:
- fixtures: builds all test fixtures (runs on "unit")
- fixtures:clean: cleans all fixture caches (runs on "clean")
- fixtures:directories: lists all fixture directories
- fixtures:fingerprint: outputs a hash of all fixture files for caching
func Tasks ¶
func Tasks(options ...Option) Task
Tasks creates a test task that runs Go tests with coverage reporting. The task hooks into the "test" label, so it runs whenever "make test" is called. By default, it runs tests for all packages with coverage enabled and race detection in CI environments.
Example:
gotest.Tasks() // default: run all tests
gotest.Tasks(gotest.Name("integration")) // named test suite
gotest.Tasks(gotest.ExcludeGlob("**/test/**")) // exclude paths
Types ¶
type Config ¶
type Config struct {
// Name identifies this test suite (e.g., "unit", "integration"). Used in logs.
Name string
// IncludeGlob specifies which packages to test (default: "./...").
IncludeGlob string
// ExcludeGlob filters out packages matching this pattern.
ExcludeGlob string
// Verbose enables verbose test output (-v flag).
Verbose bool
// Coverage enables coverage reporting (default: true).
Coverage bool
// CoverageFile specifies where to write coverage data. If empty, uses temp file.
CoverageFile string
// CoverageThreshold is the minimum total coverage percentage required to pass.
// If > 0, the task fails when measured coverage falls below this value, or
// when the coverage percentage cannot be parsed from the report. Requires
// Coverage to be enabled.
CoverageThreshold float64
// Race enables race detector (-race flag). Defaults to true in CI on non-Windows.
Race bool
// Tags specifies build tags to use during testing.
Tags []string
// RunFilter limits which tests run (-run flag pattern).
RunFilter string
}
Config holds configuration for the test task.
type Option ¶
type Option func(*Config)
Option is a functional option for configuring test tasks.
func CoverageThreshold ¶ added in v0.4.0
CoverageThreshold sets the minimum total coverage percentage required to pass. Values <= 0 disable the check. If measured coverage falls below this value, the task fails. Example: gotest.CoverageThreshold(80) requires at least 80%.
func ExcludeGlob ¶ added in v0.1.0
ExcludeGlob sets a pattern to exclude packages from testing.
func IncludeGlob ¶ added in v0.1.0
IncludeGlob sets which packages to include in testing (default: "./...").