Just run single test instead of the whole suite?


I have a test suite for a Go package that implements a dozen tests. Sometimes, one of the tests in the suite fails and I’d like to re-run that test individually to save time in debugging process. Is this possible or do I have to write a separate file for this every time?


Use the go test -run flag to run a specific test. The flag is documented in
the testing flags section of the go tool documentation:

-run regexp
    Run only those tests and examples matching the regular

Answered By – Simon Fox

Answer Checked By – Clifford M. (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.