-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Use with Gradle
Make sure these lines are in your build.gradle
plugins {
java
}
dependencies {
testImplementation('junit:junit:4.13')
}
See Gradle Java tests for configuration information. In short:
./gradlew test
There is nothing extra that needs to be done in order to use a specific artifact of Hamcrest. In the past, there were two JUnit Maven artifacts: junit:junit
and junit:junit-dep
, where the latter version did not include a bundled copy of org.hamcrest:hamcrest-core
and instead declared a transitive dependency on Hamcrest. In order to be more Maven-like, starting in version 4.11, there is only the junit:junit
artifact which uses a transitive dependency on hamcrest-core
.
Instead of using junit:junit
as your test dependency, you should use junit:junit-dep
along with specifying a particular Hamcrest library dependency beforehand. For example:
dependencies {
testCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
testCompile group: 'junit', name: 'junit-dep', version: '4.10'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.+'
}