AssertJ断言系列<一>
1 - Get AssertJ Core assertions
Maven的pom.xml加入如下配置:
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<!-- use 2.9.1 for Java 7 projects -->
<version>3.11.1</version>
<scope>test</scope>
</dependency>
2 - Add AssertJ methods static import静态导入
import static org.assertj.core.api.Assertions.*;
3 - Test
@Test
public void listTest() {
//断言list
List<String> name = new ArrayList<String>();
name.add("hello");
name.add("world");
name.add("java");
name.add("jack");
assertThat(name).isNotNull().isInstanceOf(name.getClass());
assertThat(name).isNotNull().hasSize(4).contains("hello", name.get(0));
assertThat(name).hasSize(4).contains("hello","world").doesNotContain("javaee");
}