feat(mocktesting): initial implementation

This commit is contained in:
2021-11-21 22:03:11 +00:00
parent 7209ef72c6
commit 5b84721b10
11 changed files with 3564 additions and 0 deletions

23
mocktesting.go Normal file
View File

@@ -0,0 +1,23 @@
// Package mocktesting provides a mock of *testing.T for the purpose of testing
// test helpers.
package mocktesting
import (
"sync"
)
// Go runs the provided function in a new goroutine, and blocks until the
// goroutine has exited.
//
// This is essentially a helper function to avoid aborting the current goroutine
// when a *T instance aborts the goroutine that any of FailNow(), Fatal(),
// Fatalf(), SkipNow(), Skip(), or Skipf() are called from.
func Go(f func()) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
f()
}()
wg.Wait()
}