alexruiz / fest-assert-2.x

FEST Fluent Assertions 2.x
http://fest.easytesting.org
Apache License 2.0
401 stars 69 forks source link

Remove methods from *ArrayAssert that take an object to compare size #113

Open alexruiz opened 12 years ago

alexruiz commented 12 years ago

For example, we have a method that takes an Iterable and asserts that an array has the same size. This is unnecessary API explosion. We need to draw the line somewhere. Now we compare to Iterable and Object array, which give users the idea they can request size comparison to whatever type they think they need, e.g. a Map and so on.

To assert the size of an array, just pass the expected size. If users have to compare it to the size of an array, get the size of such array and do an assertThat(array).hasSize(#number).

ash2k commented 12 years ago

Pros for such methods:

assertThat(array).hasSameSizeAs(collection);

reads a lot better than

assertThat(array).hasSize(collection.size());

The less steps it takes reader to get the assertion the better.

Cons:

p.s. Original feature request http://jira.codehaus.org/browse/FEST-221 p.s.s. If Map have .size() then why can't you assert that an array have the same number of elements as there are mapping in the map?

alexruiz commented 12 years ago

I'm sorry, but I don't agree. I can see having the same argument over hasSameSize(byte[]) and all the primitive arrays or some crazy stuff as hasSameSize(String), hasSameSize(StringBuilder). We can revisit this feature after 2.0 is released.