Running one golang test in folder with many _test.go files?

Hello, if I have a folder with multiple xxx_test.go files, how do I just run a single test? For example, in AlecThomas gometalinter package, he has a folder called regressiontests and it has over 20 tests in it. How would one run just one test? Or is it the case that the Regression tests should be considered as one unbreakable entity and run all at once?

You can use go test -run TestName.

1 Like

Thanks, Stratos, am I right in thinking that the test name refers to the name(s) of the test function(s) inside the file, rather than the filename itself?

Yes exactly. In fact go test -run Foo will run both functions TestFooBar and TestFooBaz.

Understood. Thanks very much!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.