Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


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

alexruiz opened this Issue · 2 comments

2 participants


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).

@alexruiz alexruiz was assigned

Pros for such methods:

  • readability, the test author's intent is captured more precisely:

reads a lot better than


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

  • "write-ability". I choose fest-assert over plain testng/junit assertions because it have all this kind of assertion methods that are very convenient to use. It's like fest-assert goes one step further than others, do a bit more for you, saving keystrokes.


  • A little API explosion?. Yes, for "regular" libraries it would have been. But not for testing framework imo. The whole library is an API explosion compared to Java's assert keyword :)

p.s. Original feature request
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?


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.