mirror of
https://github.com/jimeh/go-mocktesting.git
synced 2026-02-19 11:56:39 +00:00
feat(mocktesting): initial implementation
This commit is contained in:
23
mocktesting.go
Normal file
23
mocktesting.go
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user