gotest

Specification-driven test suites for Go with isolation and parallelism as first-class citizens.
Write test suites as Go structs.
gotest generates the test functions that hand them to its runtime, and runs each suite in a process of its own.
The compiler, the testing package and the output are go test's; the runner is gotest.
What you read back is a behavioral specification.
The code your tests link imports only the standard library. Suites are found and registered by code generation, never by reflection.
Contents
Why gotest?
Go's testing package gives you func TestX(t *testing.T) and nothing more.
Setup/teardown logic is copy-pasted or buried in TestMain.
As test suites grow, organization becomes a discipline problem rather than a tooling one.
testify/suite solves organization but adds runtime reflection, interface dispatch, and a suite.Run(t, new(MySuite)) ceremony in every file.
Test output is standard — but the mechanism behind it isn't.
gotest takes a different approach:
- Specification-driven. BDD vocabulary (
When/It) structures tests as readable behavioral contracts. gotest spec renders them as documentation — in the terminal, as markdown, or as structured JSON. Always in sync, never stale.
- Isolated by default. Each suite runs in its own process, so suites share no memory, no package-level state and no
init side effects. Within a suite the methods share one struct value: BeforeEach gives each method fresh state, and a field one method writes is there for the next unless a hook resets it.
- Parallel on two levels. Suites run in parallel automatically, as separate processes. Methods run in parallel when the suite opts in, and each then gets its own state from a
BeforeEach that returns it. The generator refuses a parallel suite whose BeforeEach returns nothing; it cannot see a method that writes a suite field, so run parallel suites under -race.
Under the hood, gotest generates one func Test<Suite>(t *testing.T) per suite: a table of the suite's hooks and methods, handed to the pkg/gotestruntime library, which runs each method as a subtest, keeps setup and teardown in order and holds the timeouts.
Generated files never touch your source tree: they reach the compiler through a build overlay and are removed after the run.
gotest's own behavioral promises are stated once in specs/, each scenario bound to a test; this README explains them and links there.
How It Works
you write: gotest generates: gotest runs:
(in a build overlay)
MySuite struct gotest_psuite_test.go one process per suite:
BeforeAll() → func TestMySuite(t) → BeforeAll()
TestFoo() OpenSuite(hooks) t.Run("TestFoo", ...)
AfterAll() RunMethods(methods) AfterAll()
The generated file is short: a wrapper type and one call each to gotestruntime.OpenSuite and gotestruntime.RunMethods, with your hooks and methods passed as plain function values. gotest generate ./... writes it to disk when you want to read it.
Suites are found by reading the source, and the generated code calls your methods directly: no reflection finds or dispatches a test. Assertions such as Equal use reflect to compare values.
What It Costs