Home >Backend Development >Golang >How Can I Run a Specific Test Within a Go Test Suite?
Run Specific Tests in Go Test Suites
This question asks how to run a single test from a test suite in Go.
Answer:
To run a specific test from a Go test suite, use the -run flag of the go test command. The -run flag is documented in the testing flags section of the go tool documentation:
-run regexp Run only those tests and examples matching the regular expression.
For example, to run only the TestMyFunction test in the foo package:
go test -run 'TestMyFunction' ./foo
This is a convenient way to save time in the debugging process by re-running only the failed test.
The above is the detailed content of How Can I Run a Specific Test Within a Go Test Suite?. For more information, please follow other related articles on the PHP Chinese website!