subtest
A named test run inside another test, with its own pass or fail result, often one per case in a table of inputs.
In more detail
Go creates one with t.Run and Node's built-in test runner with t.test(). Each subtest reports separately, so a failure names the exact case, and a failing subtest marks its parent test as failed too. In Go, go test -run with a pattern can run one subtest on its own.
Example
t.Run(tc.name, func(t *testing.T) {})Related terms
- table-driven test — A Go test style that lists many input cases and expected results as rows in a slice, then checks them all in one loop.
- Go testing package — Go's standard library package for writing tests, run by the go test command.
- t.Error and t.Fatal — The *testing.T methods that mark a test as failed: the Error forms continue running the test, the Fatal forms stop it immediately.
- test suite — A collection of tests run together to check a piece of software.
- test runner — A tool that finds test files, runs the tests in them and reports which passed and which failed.
Taught in
- Writing Table Driven Tests — Concurrent Systems Programming with Go
- Native Test Runner: node:test & node:assert/strict — Node.js Internals & Backend Services