Issue
import static org.junit.matchers.JUnitMatchers.both;
import static org.junit.matchers.JUnitMatchers.containsString;
Now I check it contains foo and bar as below ...
Assert.assertThat(text,
both(containsString("foo")).
and(containsString("bar")));
What is cleanest way to test that it contains 3 or more strings e.g. 'foo', 'bar' and 'baz' ?
Solution
Use AllOf
Assert.assertThat(test, CoreMatchers.allOf(
containsString("foo"),
containsString("bar"),
containsString("bar2"),
containsString("ba3")));
Answered By - John B
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)