-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Assertions.assertNotNull()
should return the non-null object
#4015
Comments
If using AssertJ is an option, with version 3.27.0 it will be possible to write the following: import static org.assertj.core.api.Assertions.assertThat;
...
Foo foo = assertThat(bar.doSomething()).isNotNull().actual().getFoo(); See assertj/assertj#3489. |
Hello @scordio Thank you for your reply. I'll be honest with you: I'll never write this kind of extra verbose code. I feel that this obfuscates what the test is trying to show. The reason I gave this example is because I want less code, not more ;-) I'll stick with the straightforward for now :) |
Totally understandable 😉 a pure non-null assertion is not the best showcase for that, but users find it handy for more complex use cases. As with everything, YMMV 🙂 |
And do I have miles! 😜 |
Changing the result type of |
I agree BC is key, this would be for 6.0. Nice idea using requireNonNull 👍 |
Assertions.assertNotNull()
should return the non-null object
The assertNotNull is verbose and superfluous. Just write |
Hello @bjmi |
As a developer, I like to write some test code like:
Deliverables
Assertions.assertNotNull()
that returns its input and notvoid
.assertSame()
The text was updated successfully, but these errors were encountered: