Skip to content
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

If condition passed to Never does not return before waitFor, then the Never assertion passes. #1654

Open
brackendawson opened this issue Oct 4, 2024 · 1 comment · May be fixed by #1657
Labels

Comments

@brackendawson
Copy link
Collaborator

brackendawson commented Oct 4, 2024

Description

If a condition function is passed to Never which does not return once before waitFor elapses, then the assertion passes having never completed a single check.

Never asserts that the given condition doesn't satisfy in waitFor time...

Technically this is correct, but I think our implementation of it is surprising.

Step To Reproduce

func TestIfy(t *testing.T) {
	assert.Never(t, func() bool {
		time.Sleep(2 * time.Second)
		return true // this should fail
	}, time.Millisecond, time.Second)
}

Expected behavior

The test fails because the condition is statically true

Actual behavior

Test passes

@brackendawson
Copy link
Collaborator Author

I'm curious what @dolmen and @cszczepaniak think about this as you were discussing in this area over the summer. I think we should make Never, Eventually and EventuallyWithT wait for the last run of their condition functions to return, it would make their behaviour consistent when they are called with unreasonably small times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant