bean-matchers
bean-matchers copied to clipboard
Improve assertion description for hasValidGettersAndSettersExcluding("…")
Suggestion
Change the assertion description returned on fail for assertThat(BeanToTest.class, hasValidGettersAndSettersExcluding("dontTestPropertyWithThisName")) to list the expected properties, not the already known (and yet provided) excluded properties list.
We use assertions of this kind very often, because of many read-only properties:
assertThat(BeanToTest.class, hasValidGettersAndSettersExcluding("dontTestPropertyWithThisName"))
The current behavior: if assertion matcher fail, it list the the already known (and yet provided) excluded properties list within the fail-description.
This information is redundant and does not really help to exactly point/describe the issue: one or more properties have no valid setters/getters, but which of the remaining at the class under test? Expected behavior: it should instead list the properties that are found by the "magic" JavaBean (with the excluded properties subtracted). This information would really help test developers to track down to the point.
Thanks @netsrotr, this is a good suggestion. Would you like to submit a pull request?