eduncan911 / eduncan911/mspec

Refactoring: Allow Concurrently Executing Tests

Open
#7 0 comments 0 reactions 1 assignee Claimed by @eduncan911 View on GitHub
enhancement
Dominant language
Go
Stars
18
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Since Go 1.5, `GOMAXPROCS` is now set to the number of cores on the machine. When you run `go test`, Go actually compiles a temp binary that runs each `func Test(t *testing.T)` in a goroutine. But note that default behavior for Go tests is synchronously - that is, it still runs 1 test at a time.

You've always had the ability to call `t.Parallel()` before 1.5; but, this was of little use without setting `GOMAXPROCS` properly. Well now that `GOMAXPROCS` is set to the number of virtual cores by default, this means `t.Parallel()` in tests will now make the tests run concurrently.

But using this package you defeat the advantage of running 100s of unit tests concurrently and instead is forced to run each Test harness for a group of Specs - those Specs will run synchronously and thus be slower overall.

The refactoring should make heavy use of `goroutines` where appropriate, without slowing down simple tests. By moving to use `goroutines` for most inner loops, we should get the added benefit of increasing performance overall - even without the `t.Parallel()` flag being set!

See #4 for details.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.