JavaHamcrest icon indicating copy to clipboard operation
JavaHamcrest copied to clipboard

Changed signature of method containsInAnyOrder to allow avoid calling…

Open yatsenko-ihor opened this issue 5 years ago • 3 comments

Changed signature of method containsInAnyOrder to allow avoid calling toArray() method or casting to the array and build next construction

List<String> actual = Arrays.asList("a", "b", "c"); List<String> expected = Arrays.asList("a", "c"); assertThat(list, containsInAnyOrder(expected))

Some results from the internet with recommendations to call toArray(): https://stackoverflow.com/questions/21624592/hamcrest-compare-collections http://haroonzone.github.io/comparing-lists-with-hamcrest/ (ListMatcher2.java)

yatsenko-ihor avatar Oct 11 '19 16:10 yatsenko-ihor

I really like they way that this simplifies the calling code for collections of items.

Without knowing if this is true, I also worry that this will break other code that is passing collections of matchers. Can you add another test to IsIterableContainingInAnyOrderTest to verify that this doesn't cause a regression?

tumbarumba avatar Oct 16 '19 22:10 tumbarumba

@yatsenko-ihor looking at closing pr and getting merged, looks a good idea

can you keep the current signature but mark as deprecated as i'm sure if we do this change we might get bugs as a result if people are using existing signature

please can you rebase from master, as hamcrest-core and hamcrest-library have been refactored a lot and also deprecated, so that everything is just in hamcrest.

nhojpatrick avatar Jun 29 '20 21:06 nhojpatrick

Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch v2.3-candidates. Still trying to understand how has permissions to perform a release.

nhojpatrick avatar Feb 13 '22 12:02 nhojpatrick