MavenとJUnitの例
Mavenでは、次のようにJUnit依存関係を宣言できます。
pom.xml
junit junit 4.12 test
ただし、hamcrest-coreライブラリのバンドルコピーが付属しています。
$ mvn dependency:tree ... [INFO] \- junit:junit:jar:4.12:test [INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test ...
1. Maven + JUnit + Hamcrest
Notehamcrest-coreのデフォルトのJUnitバンドルコピーを使用することはお勧めできません。除外することをお勧めします。
更新されたpom.xmlを再度確認します。これにより、hamcrest-coreのJUnitバンドルコピーが除外されます。 一方、有用なhamcrest-libraryも含まれています。
pom.xml
junit junit 4.12 test org.hamcrest hamcrest-core org.hamcrest hamcrest-library 1.3 test
依存関係ツリーを再度確認します。
$ mvn dependency:tree ... [INFO] +- junit:junit:jar:4.12:test [INFO] \- org.hamcrest:hamcrest-library:jar:1.3:test [INFO] \- org.hamcrest:hamcrest-core:jar:1.3:test ...