You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
List<String> z = new ArrayList<>(Arrays.asList("a","a","a"));
assertThat(z).containsExactly("a","a");
Stacktrace:
java.lang.ArrayIndexOutOfBoundsException: 2
at org.fest.assertions.internal.Iterables.assertContainsExactly(Iterables.java:995)
at org.fest.assertions.api.AbstractIterableAssert.containsExactly(AbstractIterableAssert.java:99)
Regards, Wojtek
The text was updated successfully, but these errors were encountered:
Having said that, this assertion javadoc is misleading ... What we wanted to do with containsExactly is to assert that the actual Iterable contained all the given objects in the same order, it entails that the actual size must match the varargs size.
It means your assertion will fail (but not with an exception !), as described below :
// should fail because z has 3 elements assertThat(z).containsExactly("a","a");
// succeeds as given varargs is composed of 3 elements matching exactly z elements assertThat(z).containsExactly("a","a", "a");
You probably know that but you can use containsOnly to test z content only :
fixed in 2.0M9 branch.
I'm not closing this issue because it must be merged in master branch where a major rework for 2.0 is being done, merge will happen after the rework.
For code:
Stacktrace:
Regards, Wojtek
The text was updated successfully, but these errors were encountered: