1.要使用is()方法首先需要导入hamcrest-library-1.3.jar和hamcrest-core-1.3.jar两个jar包
依赖配置:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
import static org.junit.Assert.*;
import org.junit.Test;
import static org.hamcrest.Matchers.*;
public class TestGetName {
@Test
public void testGetName() {
assertThat(new User().getName(),is("mafx"));
}
}