public String generateGreeting(String name) { return "Hello, " + name + "!"; }
@Test public void testGenerateGreeting() { String name = "Alice"; String greeting = generateGreeting(name); assertThat(greeting, containsString(name)); }
Overall, the org.hamcrest.Matchers package provides a useful set of matchers for writing expressive and concise test cases in Java.org.hamcrest hamcrest-all 1.3