Skip to content

proposal: testing: less syntactic overhead to synctest testsΒ #76607

@rogpeppe

Description

@rogpeppe

Proposal Details

When writing tests using testing/synctest, I find myself writing very many tests that look like this:

func TestSomething(t *testing.T) {
	synctest.Test(t, func(t *testing.T) {
		...
	})
}

This means that essentially all of my test code has a double level of indentation,
and the synctest wrapper is annoying to write every time.

I wonder if it might be more convenient to have a way to mark
a given test as "synctest" and have the testing package be responsible
for doing the wrapping.

One possibility might be to use a doc-comment-style annotation:

//testing:synctest
func TestSomething(t *testing.T)

This would be picked up by the testing harness and become equivalent
to the earlier TestSomething function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions