New BeanHas and BeanProperty matchers#3
New BeanHas and BeanProperty matchers#3sandromancuso wants to merge 6 commits intohamcrest:masterfrom
Conversation
|
I'm curious -- what does this add that can't be done by combining multiple |
|
I think that hasProperty works well when testing a single property. allOf is good for combining different matchers. Using allOf and multiple hasProperty, in my view, give us a broken readability. Example: assertThat(myObject, allOf(hasProperty(...), hasProperty(...))) I think that assertThat(myObject(has(property(..), property(...)) gives a better readability. On top of that, BeanHas and BeanProperty are offering a better error message when the assertion fails. |
|
Hi guys, Is there anyone looking at the pull requests? It would be great to have some feedback. Cheers, |
|
Hey Sandro, I'm kinda looking at pull requests, although I'm concentrating on getting a release out before taking much new code in. |
|
Oh god, im am looking for that @scarytom @sandromancuso |
compile time safety |
|
@sandromancuso fancy rebasing this from master, as |
|
Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch |
9bc653b to
e9f7fc8
Compare
The idea is to be able to test multiple properties in a single assertion and get a decent error message when at least one of them does not match.
I've written these matchers and we use them in a few projects at work. We thought that it would be a good idea to contribute back to JavaHamcrest. I changed my original classes to so it would fit better the coding style used in JavaHamcrest, including the way the tests are written.
I know that Hamcrest has the allOf and hasProperty matchers. They are very good but I personally think that BeanHas and BeanProperty could be a good addition to the library since they work in a slightly different way.
For more details, I've blogged about the matchers here: http://craftedsw.blogspot.co.uk/2012/05/testing-multiple-properties-with-single.html