junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

Decouple JUnit from Hamcrest

Open marcphilipp opened this issue 10 years ago • 4 comments

@npryce has nicely summed up the reasons to do this in his blog: http://www.natpryce.com/articles/000806.html

marcphilipp avatar May 22 '15 18:05 marcphilipp

Sounds like a good plan. Let's deprecate the APIs that use Matcher on the main branch

kcooney avatar May 23 '15 01:05 kcooney

What about to declare optional dependency of Hamcrest in POM:4.13? Looks like some API are deprecated and you would force the users include their dependency of Hamcrest.

This means our POM would specify optional dependency: <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> <version>1.3</version> <optional>true</optional> </dependency> and customer does not receive Hamcrest in his classpath. Therefore the customer will specify it in his POM with the version he likes.

Tibor17 avatar May 30 '15 16:05 Tibor17

Will this also resolve the warning that com.netflix.nebula.lint produces:

warning   duplicate-dependency-class         junit:junit:4.12 in configuration ':moduleA:compile' has 21 classes duplicated by org.hamcrest:hamcrest-core:1.3 (use --debug for detailed class list) (no auto-fix available)

https://github.com/nebula-plugins/gradle-lint-plugin/issues/103

drjasonharrison avatar Mar 27 '17 16:03 drjasonharrison

@drjasonharrison I don't think that should happen with JUnit 4.12 (it doesn't ship with Hamcrest classes). Is it possible you depend on multiple versions of JUnit?

In any case, I suggest trying to create a minimal reproducible test case and ask on stackoverflow.com

kcooney avatar Mar 27 '17 17:03 kcooney