因爲要引入Hamcrest的一些東西,所以需要使用如下import 代碼:
import static org.hamcrest.Matchers.*
pom已經引入了 junit 4.11
但是這個引入就是報錯,後來走官網才發現,還需要引入 hamcrest-library
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
引入後,使用就沒有問題了。
assertThat( mapVar1, is(mapVar2));