Skip to content

proposal: testing: add Test function #32067

@rogpeppe

Description

@rogpeppe

The testing package has long contained the Benchmark function, which allows code in a non-testing source file to run benchmarks.

It is sometimes useful to be able to run test code in a non-testing context too; for example to demonstrate a failing test in the Go playground.

Perhaps something like this?

// Test runs f as a test with the given name. Any test output
// is written to w. Test reports whether the test has succeeded.
func Test(w io.Writer, name string, f func(t *testing.T)) bool

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions