-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assert: collect.FailNow() should not panic (#1481)
## Summary `collect.FailNow()` should exit goroutine without a panic to be usable with `require` package. ## Changes `collect.FailNow()` just does `runtime.Goexit()` instead of `panic()`. For example `FailNow()` from `testing` package [behaves similarly](https://cs.opensource.google/go/go/+/refs/tags/go1.21.2:src/testing/testing.go;l=973). ## Motivation I just want `require` package to be usable with `EventuallyWithT` e.g. I want this example to pass but it panics: ```go package main import ( "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestRequireEventuallyWithT(t *testing.T) { state := 0 require.EventuallyWithT(t, func(c *assert.CollectT) { defer func() { state += 1 }() require.True(c, state == 2) }, 100*time.Millisecond, 10*time.Millisecond) } ``` See https://go.dev/play/p/Oqd95IT7qxQ ## Related issues Fixes #1396 Fixes #1457
- Loading branch information
1 parent
84619f5
commit b074924
Showing
3 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters