「JUnitのpom.xmlの設定」の版間の差分
提供: tknotebook
(ページの作成:「Category:コンピュータCategory:JavaCategory:Maven メインページ>コンピュータの部屋#Java>Maven Tips おなじみの単...」) |
(相違点なし)
|
2016年11月20日 (日) 23:29時点における最新版
メインページ>コンピュータの部屋#Java>Maven Tips
おなじみの単体試験ツール JUnit は Maven の設定で必須と言ってよいですが、
4.4 以降 hamcrestライブラリに依存していて自動的に hamcrestライブラリも
ダウンロードされます。
しかし、hamcrestライブラリは hamcrest-all の方が使えるマッチャーが多いので便利です。 以下のように設定すると、hamcrest-allが使えます。
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
hamcrestもダウンロードされてしまいますが、hamcrest-all がクラスパスの先に入ります。 必ず、hamcrest-allを先に指定するようにしてください。