Skip to content

Instantly share code, notes, and snippets.

@wolfgangmeyers
Created October 21, 2016 20:28
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wolfgangmeyers/dae31604aebee87b198f3ad34b37b23e to your computer and use it in GitHub Desktop.
Save wolfgangmeyers/dae31604aebee87b198f3ad34b37b23e to your computer and use it in GitHub Desktop.
How to count the number of running tests for a go project
go test ./... -v | grep -c RUN
@anshupitlia
Copy link

Wonderful.

@peterstace
Copy link

Note that this will count tests as well as subtests. This is essentially double counting if your all your regular tests do is spin off subtests.

(commenting, because this is the top google result for "golang number of tests")

@wolfgangmeyers
Copy link
Author

Note that this will count tests as well as subtests. This is essentially double counting if your all your regular tests do is spin off subtests.

(commenting, because this is the top google result for "golang number of tests")

That's a good point. I think that at when I posted this, I was still using Go 1.6. I'd probably use something like python to parse the subtest output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment