-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert.Eventually() does not fail test when the timer expires #837
Comments
If I'm not mistaken, it's the |
As I was seeing the same, I did some experimentation: package main
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
// "github.com/stretchr/testify/require"
)
func TestEventually(t *testing.T) {
assert.Eventually(t, func() bool {
return false
}, 10 * time.Second, 1 * time.Second, "always false")
} With v1.4.0: duncan@linux-1cur:/space/git/testify-testcase> go test .
--- FAIL: TestEventually (10.00s)
main_test.go:12:
Error Trace: main_test.go:12
Error: Condition never satisfied
Test: TestEventually
Messages: always false
FAIL
FAIL github.com/dmacvicar/testify-testcase 10.004s With v1.4.1-0.20191106224347-f1bd0923b832 duncan@linux-1cur:/space/git/testify-testcase> go test .
go: finding github.com/stretchr/testify master
ok github.com/dmacvicar/testify-testcase 10.005s That can be traced to f1bd092 which replaced a return Fail(t, "Condition never satisfied", msgAndArgs...) with return false |
I don't think that's accurate. The other For example, in I'm currently working around this by calling It looks like @dmacvicar has already opened a PR to fix this though -- #838. Thanks for that! |
assert.Eventually() returns false (and not Fail(...)) when the timer expires.
As a result, the test does not fail.
So for example, including
assert.Eventually(t, func()bool{return false}, time.Second, time.Millisecond))
in your test does not cause it to fail. It will poll the function for a second, and then pass.Is this intentional? It seems surprising, since the other assert functions cause the test to fail when the condition is not met.
The text was updated successfully, but these errors were encountered: