truth icon indicating copy to clipboard operation
truth copied to clipboard

Truth inorder not fully documented

Open elharo opened this issue 5 years ago • 2 comments

https://truth.dev/api/0.46/com/google/common/truth/Ordered.html

This does not indicate whether intervening elements are or are not allowed. E.g. does

assertThat(list).containsAllElementsIn("a", "b", "c").inOrder();

pass or fail if list in fact contains:

"a", "z", "b", "c"

The API docs should be explicit on this point.

elharo avatar Jun 27 '19 13:06 elharo

This is documented on the methods that return Ordered. For example:

https://truth.dev/api/0.46/com/google/common/truth/IterableSubject.html#containsAtLeastElementsIn-java.lang.Iterable-

"To also test that the contents appear in the given order, make a call to inOrder() on the object returned by this method. The expected elements must appear in the given order within the actual elements, but they are not required to be consecutive."

But I agree that we can make this clearer. Thanks.

cpovirk avatar Jun 28 '19 14:06 cpovirk

That is clear. It just isn't where I naturally looked. It didn't occur to me to look for that information on the API doc for containsElementsIn instead of inOrder.

elharo avatar Jun 28 '19 14:06 elharo