Repository: mockito/mockito
Issue: Update hamcrest-core to version 1.3

Hi there,

It would be nice if mockito-core would depend on hamcrest-core 1.3 instead of 1.1 so that both mockito and junit [latest versions] would depend on the same 3rd party library.

Thanks in advance!


Issue comments:
I agree.
It would be nice to depend on a version of hamcrest-core that is not eight years old...

Hi thanks for your interest. I think your comment are indeed just right, yet compatibility has always been the primary concern here.

Nevertheless mockito 2.0.x will probably ditch the hamcrest dependency. We still have to think that through. But it will happen, hence the reason why we didn't merge this PR.

Cool, thank you for the update! Cheers!


Pull request review comments:

Patch that resolved the issue:
diff --git a/build.gradle b/build.gradle
index 66145a4d0e..0ec718a1a5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -61,7 +61,7 @@ tasks.withType(JavaCompile) {
 //TODO we should remove all dependencies to checked-in jars
 dependencies {
     provided "junit:junit:4.10"
-    compile "org.hamcrest:hamcrest-core:1.1", "org.objenesis:objenesis:2.1"
+    compile "org.hamcrest:hamcrest-core:1.3", "org.objenesis:objenesis:2.1"
     compile fileTree('lib/repackaged') { exclude '*.txt'}
 
     testCompile fileTree("lib/test")
diff --git a/src/org/mockito/internal/matchers/LocalizedMatcher.java b/src/org/mockito/internal/matchers/LocalizedMatcher.java
index b19cdf5133..d770103286 100644
--- a/src/org/mockito/internal/matchers/LocalizedMatcher.java
+++ b/src/org/mockito/internal/matchers/LocalizedMatcher.java
@@ -64,6 +64,10 @@ public void captureFrom(Object argument) {
         }
     }
 
+    public void describeMismatch(Object argument, Description description) {
+        actualMatcher.describeMismatch(argument, description);
+    }
+
     //TODO: refactor other 'delegated interfaces' to use the MatcherDecorator feature
     public Matcher getActualMatcher() {
         return actualMatcher;


Test patch:
diff --git a/test/org/mockito/internal/runners/RunnerFactoryTest.java b/test/org/mockito/internal/runners/RunnerFactoryTest.java
index 02c7abdd3b..e012bbdeef 100644
--- a/test/org/mockito/internal/runners/RunnerFactoryTest.java
+++ b/test/org/mockito/internal/runners/RunnerFactoryTest.java
@@ -1,7 +1,7 @@
-/*
- * Copyright (c) 2007 Mockito contributors
- * This program is made available under the terms of the MIT License.
- */
+/*
+ * Copyright (c) 2007 Mockito contributors
+ * This program is made available under the terms of the MIT License.
+ */
 package org.mockito.internal.runners;
 
 import static org.hamcrest.CoreMatchers.*;
@@ -37,7 +37,7 @@ public boolean isJUnit45OrHigherAvailable() {
         RunnerImpl runner = factory.create(RunnerFactoryTest.class);
         
         //then
-        assertThat(runner, is(JUnit44RunnerImpl.class));
+        assertThat(runner, instanceOf(JUnit44RunnerImpl.class));
     }
     
     @Test
@@ -54,7 +54,7 @@ public boolean isJUnit45OrHigherAvailable() {
         RunnerImpl runner = factory.create(RunnerFactoryTest.class);
         
         //then
-        assertThat(runner, is(JUnit45AndHigherRunnerImpl.class));
+        assertThat(runner, instanceOf(JUnit45AndHigherRunnerImpl.class));
     }
     
     @Test
diff --git a/test/org/mockitousage/basicapi/MocksCreationTest.java b/test/org/mockitousage/basicapi/MocksCreationTest.java
index 533826a6f4..e2e532de86 100644
--- a/test/org/mockitousage/basicapi/MocksCreationTest.java
+++ b/test/org/mockitousage/basicapi/MocksCreationTest.java
@@ -16,7 +16,7 @@
 import java.util.List;
 import java.util.Set;
 
-import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.mockito.Mockito.*;
 
 @SuppressWarnings("unchecked")
@@ -62,7 +62,7 @@ public void shouldCombineMockNameAndExtraInterfaces() {
         //then
         assertContains("great mockie", name);
         //and
-        assertThat(mock, is(List.class));
+        assertThat(mock, instanceOf(List.class));
     }
     
     @Test
diff --git a/test/org/mockitoutil/ExtraMatchers.java b/test/org/mockitoutil/ExtraMatchers.java
index bd0fe349ec..eb3e94bb9a 100644
--- a/test/org/mockitoutil/ExtraMatchers.java
+++ b/test/org/mockitoutil/ExtraMatchers.java
@@ -133,7 +133,7 @@ public void assertValue(Collection value) {
         };
     }
     
-    public static org.hamcrest.Matcher<java.lang.Object> clazz(java.lang.Class<?> type) {
+    public static <T> org.hamcrest.Matcher<T> clazz(java.lang.Class<T> type) {
         return CoreMatchers.is(type);
     }