I am using Hamcrest 1.3 and trying to do the following in a more compact way.
Consider the following test case:
@Test public void testCase() throws Exception { Collection<String> strings = Arrays.asList( "string one", "string two", "string three" );
The goal here is to check both the size of the collection and some specific elements that will be included.
If the first variation is possible and accepted, it is not always so simple to do, because perhaps the collection itself is the result of some other operations, and therefore it makes sense to do all operations on it using the allOf operation. This is done in the second version above.
However, containing the second variation code will result in the following compile-time error:
error: no suitable method found for allOf(Matcher<Collection<? extends Object>>,Matcher<Iterable<? extends String>>)
Is there any specific testing method for size items and collection items in Hamcrest using a single shot operation (like allOf )?
source share