Why does this test fail? I know contains works when you pass in individual strings separated by commas but I wanted to see if it's possible to just pass in an entire list of strings instead. I just want to make sure that list 1 contains all of the contents of list 2.
@Test
public void testContains() {
String expected1 = "hello";
String expected2 = "goodbye";
List<String> expectedStrings = new ArrayList<>();
expectedStrings.add(expected1);
expectedStrings.add(expected2);
List<String> actualStrings = new ArrayList<>();
actualStrings.add(expected1);
actualStrings.add(expected2);
assertThat(actualStrings, contains(expectedStrings));
}
Is it considered acceptable to use this assertion instead?
assertThat(actualStrings, is(expectedStrings));