Skip to content

Refactoring: Allow Concurrently Executing Tests #7

@eduncan911

Description

@eduncan911

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions