Run Single Group of Test in Golang
15 Apr 2020If there are more cases in a test file, it would be difficult to debug the failing test. Today, I learned about a simple command that can increase my focus and productivity while testing in Golang. Suppose, we have multiple function to test and it is organized as
func TestMathSum(t *testing.T) {
...
}
func TestMathProduct(t *testing.T) {
...
}
In Golang to test the whole file, following command can be used:
$ go test mathutil_test
To test only Sum method, following command can be used:
$ go test mathutil_test -run MathSum
Reference: Stackoverflow