Пример Gradle и JUnit
В Gradle вы можете объявить зависимость JUnit следующим образом:
build.gradle
apply plugin: 'java' dependencies { testCompile 'junit:junit:4.12' }
По умолчанию JUnit поставляется с копиейhamcrest-core
в комплекте.
$ gradle dependencies --configuration testCompile testCompile - Compile classpath for source set 'test'. \--- junit:junit:4.12 \--- org.hamcrest:hamcrest-core:1.3
1. Gradle + JUnit + Hamcrest
Обычно нам нужна полезная библиотекаhamcrest-library
, поэтому лучше исключить связанную копию JUnithamcrest-core
и включить исходную библиотекуhamcrest-core
. Просмотрите обновленныйpom.xml
еще раз.
build.gradle
apply plugin: 'java' dependencies { testCompile('junit:junit:4.12'){ exclude group: 'org.hamcrest' } testCompile 'org.hamcrest:hamcrest-library:1.3' }
Еще раз просмотрите зависимость.
$ gradle dependencies --configuration testCompile testCompile - Compile classpath for source set 'test'. +--- junit:junit:4.12 \--- org.hamcrest:hamcrest-library:1.3 \--- org.hamcrest:hamcrest-core:1.3