您的位置:首页 > 其它

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

2017-09-29 21:25 477 查看
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"));
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: