JUnitのpom.xmlの設定
提供: tknotebook
メインページ>コンピュータの部屋#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を先に指定するようにしてください。