-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
HasPropertyWithValue #242
Comments
No such assertion indeed. In that case, I would rather use: assertThat(foo.getAmount()).isEqualTo(5)
assertThat(foo.getName()).isEqualTo("Someone"); or even better, I would write a custom assertion class for assertThat(foo).hasAmount(5).hasName("Someone"); If you are too lazy like me to write your own assertion classes, just use the assertion generator. |
OK. If I get the time, maybe I can make a pull request 😄 |
Considering the alternatives I have suggested, I'm not convinced by the usefulness of such assertions. |
It just gives another option. Maybe not all cases warrant a custom assertion class; like if you are only using an object in one test. I do agree though that if you are going to be doing a significant amount of tests around a specific class, you are better off with a custom assertion class. Also, originally I was thinking that all of the chained conditions would be checked on failure. But is that not the case? If If only the first failure is reported, then it would just be easier to write multiple asserts as in your first example. |
By default, only the first failure is reported whether you chain or not your assertions. |
I guess this can be closed, as 77ab461 added #hasFieldOrPropertyWithValue |
Indeed ! |
I have looked and not found it in the API. I could be overlooking it, but it would be great to be able to do the following:
The text was updated successfully, but these errors were encountered: