Parallel test execution in Go

Last updated 78 days ago by Eleni Fragkiadaki

golang

Since version 1.7 the Go testing package provides the ability to run some of the tests in parallel (well not entirely in parallel but that is another blog post 😉). This is optional functionality you can enable by adding a single line of code t.Parallel() in your subtests. But how does that work exactly and what does Go actually do with these tests?

Setting up

You can find the source code for this blog post under my Github profile. The repository includes the sort library with an implementation of the Counting Sort algorithm (a stable sorting algorithm) along with the tests that make sure that our code works.
The structure of the repository is shown below – we can see the count_sort.go package and the corresponding test package (which is named the same just suffixed with _test).

## Tests, table tests and sub-tests in Go

Each test in Go is a function inside an _test.go file that roughly looks like this:

Read full Article