<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
import org.junit.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
public class MyTestClass {
@Test
public void testStringLength() {
String str = "Hello World";
assertThat(str, is(not(nullValue())));
assertThat(str.length(), is(greaterThan(0)));
assertThat(str.length(), equalTo(11));
}
}