1 2 3 4

AssertJ断言系列<一>

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>

 

import static org.assertj.core.api.Assertions.*;

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

}


 

posted @ 2019-01-21 15:00  玩出梦想  阅读(1275)  评论(0编辑  收藏  举报