Is there a nicer way to write in jUnit
String x = "foo bar";
Assert.assertTrue(x.contains("foo"));
If you add in Hamcrest and JUnit4, you could do:
String x = "foo bar";
Assert.assertThat(x, CoreMatchers.containsString("foo"));
With some static imports, it looks a lot better:
assertThat(x, containsString("foo"));
The static imports needed would be:
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.containsString;