-
Notifications
You must be signed in to change notification settings - Fork 259
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
FAQ entry: Why we don't support multiple chained calls to assertion methods on the same Subject #884
Comments
We don't provide an easier way to do this. We should write about why in the FAQ. Most of the reason is that we were concerned about confusion between this sort of "chaining" and the sort of "chaining" that we provide with assertions like assertThat(someList)
.containsExactly(a, b)
.inOrder(); Is that an assertion that the list contains Another contributing factor is that this approach is only reliably possible if most (Kotlin provides a syntax that makes this work better, and we may try to make it work still better there: #572) I'm going to re-purpose this issue to about about adding a FAQ entry. |
(That FAQ entry can also mention the specific approach you discuss in the PR you cross-linked -- using regex instead of |
I expect everyone to want this at one time or another. But our equation is basically: a moderate API convenience isn't worth even the smallest risk of user confusion (especially user confusion that can lead to false-negative assertions!). (If we mention the regex workaround we should note that that switch could easily be a step backward in error message usefulness.) |
Hi
I have the following assertions:
As you can see I make several assertions over one
str
objectIt would be easier to understand if all assertions were combined together like:
I know there are several ways how to overcome it (assign
assertWithMessage(errorMessage).that(str)
to variable and call assertions for it or by using regular expressions), but sequential invocation of assert methods over one object seems more natural to mePlease guide me, if such functionality already exists
The text was updated successfully, but these errors were encountered: