Skip to content

Commit 65f7386

Browse files
Merge pull request #1710 from greg0ire/doc-goroutine-restriction
Document consequences of calling t.FailNow()
2 parents 5a5ac85 + b1c9368 commit 65f7386

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mock/mock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ func (m *Mock) TestData() objx.Map {
331331
Setting expectations
332332
*/
333333

334-
// Test sets the test struct variable of the mock object
334+
// Test sets the [TestingT] on which errors will be reported, otherwise errors
335+
// will cause a panic.
336+
// Test should not be called on an object that is going to be used in a
337+
// goroutine other than the one running the test function.
335338
func (m *Mock) Test(t TestingT) {
336339
m.mutex.Lock()
337340
defer m.mutex.Unlock()

require/doc.go

Lines changed: 2 additions & 0 deletions
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)