ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aleksei Zaitsev <ign...@alexzaitzev.pro>
Subject Mockito 1.9.5 and JUnit 4.11 incompatibility
Date Thu, 28 Sep 2017 14:02:29 GMT
Hi, guys.

There is a known issue, that mockito 1.9.5 and JUnit 4.11 are not compatible: https://code.google.com/archive/p/mockito/issues/397

In our project we have these versions of libraries, so when someone wants to write "red" unit
test, like this one:

import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class FailureTests {
    public void reproduceMockitoAndJUnit() {
        int expected = 8;
        int actual = 2 + 2 * 2;

        assertThat(actual, is(expected));

He gets an error:
java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V

at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:8)
at org.apache.ignite.XmlConverterTest.xmlBuildsCorrectlyForNonEmptyClassWithEmbeddedIgniteClass(XmlConverterTest.java:58)

instead of normal error message:
Expected: is <8>
     but: was <6>

Briefly, in JUnit 4.11 was introduced harmcrest library 1.3, which adds a new method describeMismatch
and since the shadowing interface org.hamcrest.Matcher in mockito-all does not have this method,
we get the error mentioned above.

I want to create a Jira issue for this and fix it.

And one more question. Considering intention to migration to Java 8(or even 9) are we going
to update JUnit to version 5 and mockito to 2.* versions? If yes, I could also create tickets
for this and do this later.

View raw message