← Back Home

running a single test multiple times in golang

  1. golang
  2. blog

go provides a great standard library for testing. To test a function/method, just create name_test.go in same package and write you tests.

Go also provides go test tool to run the tests in a package. running go test in a package runs all the tests in that package and go test -run <testname> runs only given test.

But what if you want to run test multiple times, go test to rescue,

go test -run <testname> -count 100

will run given test 100 times.