mercredi 25 novembre 2015

Complex asserts on collections

I have an actual list of strings generated in my integration test and an expected list of substrings. It is trivial to assert that the collections are equal, e.g.:

assertThat(actual).containsExactly(expected);

In my case it is a bit more difficult though, because I would effectively like to have a containsExactlySubstring() function -- that is I would like to assert that there is a one-to-one correspondence between the actual strings and expected substrings. Is there a neat (descriptive) way to implement it out of the box?

Aucun commentaire:

Enregistrer un commentaire