Repository: mockito/mockito
Issue: Upgrade to Hamcrest 1.3 in pom

I know this may be a meaningless case because of #154, but if you're going to [continue to release versions of Mockito that include hamcrest as a required dependency in the pom](http://central.maven.org/maven2/org/mockito/mockito-core/2.0.13-beta/mockito-core-2.0.13-beta.pom), could you at least upgrade it to 1.3? JUnit 4.11 has been out, using Hamcrest 1.3 since 2012.

[Related Stack Overflow question](http://stackoverflow.com/questions/18770943/mockito-junit-hamcrest-versioning)


Issue comments:
Hi @durron597, no actualluy the plan is to not make hamcrest as required dependency at all, just like JUnit is a not a required dependency.

I understand that's the plan, I'm just saying, as a temporary change, in between now and the time you have hamcrest not be a required dependency at all, advancing the hamcrest version.

We can do that in 2.0 beta phase, but as development evolves API may break during that phase.
In 1.x we didn't upgrade for backward compatibility reasons.

I'll think about it.

I see no problem bumping to latest hamcrest now. PR is welcome. I hope we
can get rid of compile dependency to hamcrest. Thanks!

On Fri, Jun 12, 2015, 12:01 Brice Dutheil notifications@github.com wrote:

> We can do that in 2.0 beta phase, but as development evolves API may break
> during that phase.
> In 1.x we didn't upgrade for backward compatibility reasons.
> 
> I'll think about it.
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mockito/mockito/issues/231#issuecomment-111589566.

Thanks! One quick question though... You want a pull request for a one line change to a maven pom? I mean, I'll do it if you really need me to...

Yes please :)

On Sat, Jun 13, 2015 at 4:35 PM, durron597 notifications@github.com wrote:

> Thanks! One quick question though... You want a pull request for a one
> line change to a maven pom? I mean, I'll do it if you really need me to...
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/mockito/mockito/issues/231#issuecomment-111760394.

## 

Szczepan Faber
Founder mockito.org; Core dev gradle.org
tweets as @szczepiq; blogs at blog.mockito.org

Okay, I suppose you are using Gradle now and not Maven. I made the change in my fork, but I was searching through to make sure that's the only change needed and saw [this file](https://github.com/mockito/mockito/blob/425a6745f48a4ccb158206e23103b885da3f91b3/buildSrc/src/test/groovy/org/mockito/release/comparison/PomComparatorTest.groovy); I'm not sure what it does. Does it need to be changed as well?

Yes Mockito is built with gradle, but the script has to generate a pom file. This [pom.gradle](https://github.com/mockito/mockito/blob/master/gradle/pom.gradle) takes care of that. The test you are referring to is for the release/publish phase.

Fixed on master.


Pull request review comments:

Patch that resolved the issue:
diff --git a/build.gradle b/build.gradle
index 8f7c9ac72f..d78688fc05 100644
--- a/build.gradle
+++ b/build.gradle
@@ -62,8 +62,8 @@ tasks.withType(JavaCompile) {
 dependencies {
     compile 'net.bytebuddy:byte-buddy:0.6.8'
 
-    provided "junit:junit:4.10"
-    compile "org.hamcrest:hamcrest-core:1.1", "org.objenesis:objenesis:2.1"
+    provided "junit:junit:4.11"
+    compile "org.hamcrest:hamcrest-core:1.3", "org.objenesis:objenesis:2.1"
 
     testCompile 'org.ow2.asm:asm:5.0.4'
     testCompile fileTree("lib/test")
diff --git a/src/org/mockito/internal/matchers/LocalizedMatcher.java b/src/org/mockito/internal/matchers/LocalizedMatcher.java
index 7aeb79a73f..7adb94fb22 100644
--- a/src/org/mockito/internal/matchers/LocalizedMatcher.java
+++ b/src/org/mockito/internal/matchers/LocalizedMatcher.java
@@ -31,7 +31,11 @@ public void _dont_implement_Matcher___instead_extend_BaseMatcher_() {
     public boolean matches(Object item) {
         return actualMatcher.matches(item);
     }
-
+    
+    public void describeMismatch(Object item, Description description) {
+        actualMatcher.describeMismatch(item, description);
+    }
+    
     public void describeTo(Description description) {
         actualMatcher.describeTo(description);
     }
@@ -68,4 +72,4 @@ public void captureFrom(Object argument) {
     public Matcher getActualMatcher() {
         return actualMatcher;
     }
-}
\ No newline at end of file
+}


Test patch:
diff --git a/test/org/mockito/internal/runners/RunnerFactoryTest.java b/test/org/mockito/internal/runners/RunnerFactoryTest.java
index 7620ed7197..4b8ba78074 100644
--- a/test/org/mockito/internal/runners/RunnerFactoryTest.java
+++ b/test/org/mockito/internal/runners/RunnerFactoryTest.java
@@ -37,7 +37,7 @@ public boolean isJUnit45OrHigherAvailable() {
         RunnerImpl runner = factory.create(RunnerFactoryTest.class);
         
         //then
-        assertThat(runner, is(JUnit44RunnerImpl.class));
+        assertThat(runner, isA(JUnit44RunnerImpl.class));
     }
     
     @Test
@@ -54,7 +54,7 @@ public boolean isJUnit45OrHigherAvailable() {
         RunnerImpl runner = factory.create(RunnerFactoryTest.class);
         
         //then
-        assertThat(runner, is(JUnit45AndHigherRunnerImpl.class));
+        assertThat(runner, isA(JUnit45AndHigherRunnerImpl.class));
     }
     
     @Test
@@ -118,4 +118,4 @@ public RunnerImpl newInstance(String runnerClassName, Class<?> constructorParam)
         //then
         catch (InvocationTargetException e) {}
     }
-}
\ No newline at end of file
+}
diff --git a/test/org/mockitousage/basicapi/MocksCreationTest.java b/test/org/mockitousage/basicapi/MocksCreationTest.java
index 533826a6f4..732295a112 100644
--- a/test/org/mockitousage/basicapi/MocksCreationTest.java
+++ b/test/org/mockitousage/basicapi/MocksCreationTest.java
@@ -62,7 +62,7 @@ public void shouldCombineMockNameAndExtraInterfaces() {
         //then
         assertContains("great mockie", name);
         //and
-        assertThat(mock, is(List.class));
+        assertThat(mock, isA(List.class));
     }
     
     @Test
@@ -100,4 +100,4 @@ public void shouldAllowInlineMockCreation() throws Exception {
         when(mock(Set.class).isEmpty()).thenReturn(false);
     }
 
-}
\ No newline at end of file
+}
diff --git a/test/org/mockitoutil/ExtraMatchers.java b/test/org/mockitoutil/ExtraMatchers.java
index bd0fe349ec..bce921ec6e 100644
--- a/test/org/mockitoutil/ExtraMatchers.java
+++ b/test/org/mockitoutil/ExtraMatchers.java
@@ -134,7 +134,7 @@ public void assertValue(Collection value) {
     }
     
     public static org.hamcrest.Matcher<java.lang.Object> clazz(java.lang.Class<?> type) {
-        return CoreMatchers.is(type);
+        return CoreMatchers.isA(type);
     }
 
     public static Assertor hasMethodsInStackTrace(final String ... methods) {
@@ -147,4 +147,4 @@ public void assertValue(Throwable value) {
             }
         };
     }
-}
\ No newline at end of file
+}