Skip to content

Commit 89086b0

Browse files
committed
Document consequences of calling t.FailNow()
These comments are adapted from t.FailNow()'s own documentation. Closes #1701
1 parent f784abc commit 89086b0

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

mock/mock.go

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ func (m *Mock) TestData() objx.Map {
332332
*/
333333

334334
// Test sets the test struct variable of the mock object
335+
// Test should not be called on an object that is going to be used in a
336+
// goroutine other than the one running the test function.
335337
func (m *Mock) Test(t TestingT) {
336338
m.mutex.Lock()
337339
defer m.mutex.Unlock()

require/doc.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
//
2424
// The `require` package have same global functions as in the `assert` package,
2525
// but instead of returning a boolean result they call `t.FailNow()`.
26+
// A consequence of this is that it must be called from the goroutine running
27+
// the test function, not from other goroutines created during the test.
2628
//
2729
// Every assertion function also takes an optional string message as the final argument,
2830
// allowing custom error messages to be appended to the message the assertion method outputs.

0 commit comments

Comments
 (0)