-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
Add warning if (Async)Assertion.{Should*,*To*}
is not called
#561
Comments
I'm wondering for quite some time now if it is possible at all to detect that neither One idea that comes to my mind might be registering any |
That's probably more for a linter? |
I just realized this applies to err := fmt.Errorf("foo")
Expect(err)
// oops, forgot .To(Succeed()) So this is rather a general thing and not specific to |
Yeah, I was wondering about that as well. That's why I opened this issue. Maybe someone comes up with a clever idea :)
True, a linter would also be my fallback option. |
AsyncAssertion.{Should,ShouldNot}
is not called(Async)Assertion.{Should*,*To*}
is not called
sorry for the delay y'all. I do think this is better suited for a linter. @thediveo has captured the options that come to mind for me as well and I agree about their limitations. |
Thanks for the feedback! |
@timebertt I found this thread when trying to see if anyone had written exactly the tool you wrote. I would be interested in having it more easily available - would you be open to contributing it to golangci-lint, or would you be okay with someone else adding it? |
@ecordell I would be happy to see this linter move to a community-owned place to allow easier use and independent enhancements. |
I had an idea for checking this automatically in plain Go tests, using Any helper function can call Calling In that way, any naked |
It's easy to forget to call
Should
on async assertions when performing expectations in an async func, e.g.With this, the assertion always silently succeeds. Hence, the test code is wrong.
To reduce the likelihood of such erroneous test code, gomega could print a warning or even fail the assertion if neither
Should
norShouldNot
are called.The text was updated successfully, but these errors were encountered: