Add Subtest to run a subtest in a synctest bubble
Tests that use synctest often run each case as a subtest inside a bubble. That means nesting synctest.Test inside t.Run, which adds an extra level of indentation on top of the table-driven loop. Some developers write their own helper to avoid this.
The new synctest.Subtest function runs f in a bubble as a subtest of t named name. It is equivalent to calling t.Run with a function that calls synctest.Test.
for _, test := range tests {
synctest.Subtest(t, test.name, func(t *testing.T) {
// test body runs in a synctest bubble
})
}
- Proposal
- #77320 by neild
- Status
- Implemented on Jul 17, 2026
- Release
- Go 1.28
- Impact
- medium
- Area
- testing/synctest