在maven项目中使用Junit的assertThat()方法时,is()方法的使用

来源:互联网 发布:淘宝内部优惠券采集 编辑:程序博客网 时间:2024/06/16 08:30

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"));
}


}



阅读全文
0 0