Repository: mockito/mockito
Issue: Improve IDE UX comparison failure for JUnit5

When JUnit4 is used and the test is invoked from IDE (IDEA or Eclipse), and we are getting "arguments are different" MockitoVerificationError, the IDE gets nice "click to see the difference" link in the test failure, providing neat comparison pop-up.

We want to provide this feature for JUnit5, too. We do not want to add a new dependency on mockito (e.g. OpenTest4J). Rather, we can use reflection just like we do it now for JUnit4 or how AssertJ integrates with JUnit5.

Spin-off from #1656

Issue comments:
Changing the exception type is an incompatible change in a strict sense. However, we need to be able to improve the framework by tweaking the exceptions if needed. We always strive to be compatible. There are no known legit use cases why our users would want to catch & handle specific Mockito exceptions. It's OK to change the type of ArgumentsAreDifferent exception.
I'm happy to take this on, per your request. The hardest part was the question of whether/how to handle backward compatibility. Should have a PR submitted by Monday.
> The hardest part was the question of whether/how to handle backward compatibility

We are OK with this incompatible change (see my other comment). Thanks for taking this on!!!



Pull request review comments:
We will get to that when we switch to Java 1.8. Let's remove these comments for now.
Done.
Great! "compileOnly" is exactly the way to go!
Let's just say "JUnit", instead of "JUnit 3" in the javadocs. It will be less confusing.
Let's change "JUnit 3" -> "Junit" in all new javadoc
Can you confirm one thing for me? This import needs to change because test runtime classpath inherits opentest4j from "compileOnly"?
Yes. This was the "imperfect" behaviour I was referring to. Even though it's only using the JUnit 4 runner, it finds OpenTest4J on the classpath and uses it.
Will do. This is a hangover from the earlier prototype which also supported `org.junit.ComparisonFailure` as well as `junit.framework.ComparisonFailure`.
As above.
I started to implement this change and had a rethink. Merely saying "...if JUnit is on the class path..." is inaccurate. Specifically, `junit.framework.ComparisonFailure` must be on the classpath, which is included in JUnit 3 & 4 but not 5. So the current implementation will not throw a ComparisonFailure if JUnit 5 is on the classpath but JUnit 3/4 is not.
Thanks!
Thanks!
OK

Patch that resolved the issue:
diff --git a/build.gradle b/build.gradle
index 4285ff16ff..daee5a92b5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -78,7 +78,7 @@ configurations {
 dependencies {
     compile libraries.bytebuddy, libraries.bytebuddyagent
 
-    compileOnly libraries.junit4, libraries.hamcrest
+    compileOnly libraries.junit4, libraries.hamcrest, libraries.opentest4j
     compile libraries.objenesis
 
     testCompile libraries.asm
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index f164631907..91592b3de6 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -13,6 +13,7 @@ libraries.junitPlatformLauncher = 'org.junit.platform:junit-platform-launcher:1.
 libraries.junitJupiterEngine = "org.junit.jupiter:junit-jupiter-engine:${versions.junitJupiter}"
 libraries.assertj = 'org.assertj:assertj-core:2.9.0'
 libraries.hamcrest = 'org.hamcrest:hamcrest-core:1.3'
+libraries.opentest4j = 'org.opentest4j:opentest4j:1.1.1'
 
 libraries.bytebuddy = "net.bytebuddy:byte-buddy:${versions.bytebuddy}"
 libraries.bytebuddyagent = "net.bytebuddy:byte-buddy-agent:${versions.bytebuddy}"
diff --git a/gradle/mockito-core/osgi.gradle b/gradle/mockito-core/osgi.gradle
index 90a32eb6f8..1e942f6569 100644
--- a/gradle/mockito-core/osgi.gradle
+++ b/gradle/mockito-core/osgi.gradle
@@ -21,6 +21,7 @@ afterEvaluate {
                     'org.junit.*;resolution:=optional',
                     'org.hamcrest;resolution:=optional',
                     'org.objenesis;version="[2.5,3.0)"',
+                    'org.opentest4j.*;resolution:=optional',
                     'org.mockito.*'
 
             instruction 'Private-Package',
diff --git a/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java b/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java
index a44cc6fdb4..5a72f20f48 100644
--- a/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java
+++ b/src/main/java/org/mockito/exceptions/verification/ArgumentsAreDifferent.java
@@ -17,6 +17,19 @@ public ArgumentsAreDifferent(String message) {
         super(message);
     }
 
+    /**
+     * Three-arg constructor for compatibility with ExceptionFactory's three-arg
+     * create method. This implementation simply ignores the second and third
+     * arguments.
+     *
+     * @param message
+     * @param wanted ignored
+     * @param actual ignored
+     */
+    public ArgumentsAreDifferent(String message, String wanted, String actual) {
+        this(message);
+    }
+
     @Override
     public String toString() {
         return removeFirstLine(super.toString());
diff --git a/src/main/java/org/mockito/exceptions/verification/junit/package-info.java b/src/main/java/org/mockito/exceptions/verification/junit/package-info.java
index 4542d34b48..ad4ab7751f 100644
--- a/src/main/java/org/mockito/exceptions/verification/junit/package-info.java
+++ b/src/main/java/org/mockito/exceptions/verification/junit/package-info.java
@@ -4,6 +4,9 @@
  */
 
 /**
- * JUnit integration to provide better support for junit runners in IDEs.
+ * JUnit integration to provide better support for JUnit 4 and
+ * earlier in IDEs.
+ *
+ * @see org.mockito.exceptions.verification.opentest4j
  */
 package org.mockito.exceptions.verification.junit;
diff --git a/src/main/java/org/mockito/exceptions/verification/opentest4j/ArgumentsAreDifferent.java b/src/main/java/org/mockito/exceptions/verification/opentest4j/ArgumentsAreDifferent.java
new file mode 100644
index 0000000000..8f50d00a70
--- /dev/null
+++ b/src/main/java/org/mockito/exceptions/verification/opentest4j/ArgumentsAreDifferent.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2019 Mockito contributors
+ * This program is made available under the terms of the MIT License.
+ */
+
+package org.mockito.exceptions.verification.opentest4j;
+
+import static org.mockito.internal.util.StringUtil.removeFirstLine;
+
+import org.mockito.internal.exceptions.stacktrace.ConditionalStackTraceFilter;
+import org.opentest4j.AssertionFailedError;
+
+
+public class ArgumentsAreDifferent extends AssertionFailedError {
+
+    private static final long serialVersionUID = 1L;
+    private final String message;
+    private final StackTraceElement[] unfilteredStackTrace;
+
+    public ArgumentsAreDifferent(String message, String wanted, String actual) {
+        super(message, wanted, actual);
+        this.message = message;
+
+        unfilteredStackTrace = getStackTrace();
+        ConditionalStackTraceFilter filter = new ConditionalStackTraceFilter();
+        filter.filter(this);
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+    public StackTraceElement[] getUnfilteredStackTrace() {
+        return unfilteredStackTrace;
+    }
+
+    @Override
+    public String toString() {
+        return removeFirstLine(super.toString());
+    }
+}
diff --git a/src/main/java/org/mockito/exceptions/verification/opentest4j/package-info.java b/src/main/java/org/mockito/exceptions/verification/opentest4j/package-info.java
new file mode 100644
index 0000000000..2e84ddd662
--- /dev/null
+++ b/src/main/java/org/mockito/exceptions/verification/opentest4j/package-info.java
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2019 Mockito contributors
+ * This program is made available under the terms of the MIT License.
+ */
+
+/**
+ * Integration to provide better support for IDEs that support OpenTest4J.
+ *
+ * @see org.mocktio.exceptions.verification.junit
+ * @see org.mocktio.exceptions.verification.junit4
+ */
+package org.mockito.exceptions.verification.opentest4j;
diff --git a/src/main/java/org/mockito/internal/junit/ExceptionFactory.java b/src/main/java/org/mockito/internal/junit/ExceptionFactory.java
index ee288d614a..5db296ef5c 100644
--- a/src/main/java/org/mockito/internal/junit/ExceptionFactory.java
+++ b/src/main/java/org/mockito/internal/junit/ExceptionFactory.java
@@ -4,49 +4,58 @@
  */
 package org.mockito.internal.junit;
 
-import junit.framework.ComparisonFailure;
 import org.mockito.exceptions.verification.ArgumentsAreDifferent;
 
 public class ExceptionFactory {
 
-    private final static boolean hasJUnit = canLoadJunitClass();
-
     private ExceptionFactory() {
     }
 
-    /**
-     * If JUnit is used, an AssertionError is returned that extends from JUnit {@link ComparisonFailure} and hence provide a better IDE support as the comparison result is comparable
-     */
-    public static AssertionError createArgumentsAreDifferentException(String message, String wanted, String actual) {
-        if (hasJUnit) {
-            return createJUnitArgumentsAreDifferent(message, wanted, actual);
-        }
-        return new ArgumentsAreDifferent(message);
+    private static interface ExceptionFactoryImpl {
+        AssertionError create(String message, String wanted, String actual);
     }
 
-    private static AssertionError createJUnitArgumentsAreDifferent(String message, String wanted, String actual) {
-        return JUnitArgsAreDifferent.create(message, wanted, actual);
-    }
+    private final static ExceptionFactoryImpl factory;
+
+    static {
+        ExceptionFactoryImpl theFactory = null;
 
-    private static boolean canLoadJunitClass() {
         try {
-            JUnitArgsAreDifferent.create("message", "wanted", "actual");
-        } catch (Throwable onlyIfJUnitIsNotAvailable) {
-            return false;
+            theFactory = new ExceptionFactoryImpl() {
+                @Override
+                public AssertionError create(String message, String wanted, String actual) {
+                    return new org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent(message, wanted, actual);
+                }
+            };
+        } catch (Throwable onlyIfOpenTestIsNotAvailable) {
+            try {
+                theFactory = new ExceptionFactoryImpl() {
+                    @Override
+                    public AssertionError create(String message, String wanted, String actual) {
+                        return new org.mockito.exceptions.verification.junit.ArgumentsAreDifferent(message, wanted, actual);
+                    }
+                };
+            } catch (Throwable onlyIfJUnitIsNotAvailable) {
+            }
         }
-        return true;
+        factory = (theFactory == null) ? new ExceptionFactoryImpl() {
+            @Override
+            public AssertionError create(String message, String wanted, String actual) {
+                return new ArgumentsAreDifferent(message, wanted, actual);
+            }
+        } : theFactory;
     }
 
     /**
-     * Don't inline this class! It allows create the JUnit-ArgumentsAreDifferent exception without the need to use reflection.
-     * <p>
-     * If JUnit is not available a call to {@link #create(String, String, String)} will throw a {@link NoClassDefFoundError}.
-     * The {@link NoClassDefFoundError} will be thrown by the class loader cause the JUnit class {@link ComparisonFailure}
-     * can't be loaded which is a upper class of ArgumentsAreDifferent.
+     * Returns an AssertionError that describes the fact that the arguments of an invocation are different.
+     * If {@link org.opentest4j.AssertionFailedError} is on the class path (used by JUnit 5 and others),
+     * it returns a class that extends it. Otherwise, if {@link junit.framework.ComparisonFailure} is on the
+     * class path (shipped with JUnit 3 and 4), it will return a class that extends that. This provides
+     * better IDE support as the comparison result can be opened in a visual diff. If neither are available,
+     * it returns an instance of
+     * {@link org.mockito.exceptions.verification.ArgumentsAreDifferent}.
      */
-    private static class JUnitArgsAreDifferent {
-        static AssertionError create(String message, String wanted, String actual) {
-            return new org.mockito.exceptions.verification.junit.ArgumentsAreDifferent(message, wanted, actual);
-        }
+    public static AssertionError createArgumentsAreDifferentException(String message, String wanted, String actual) {
+        return factory.create(message, wanted, actual);
     }
 }


Test patch:
diff --git a/src/test/java/org/mockito/StaticMockingExperimentTest.java b/src/test/java/org/mockito/StaticMockingExperimentTest.java
index cc8a5988e4..c6312e75e0 100644
--- a/src/test/java/org/mockito/StaticMockingExperimentTest.java
+++ b/src/test/java/org/mockito/StaticMockingExperimentTest.java
@@ -8,7 +8,7 @@
 import org.junit.Test;
 import org.mockito.exceptions.verification.NoInteractionsWanted;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockito.invocation.Invocation;
 import org.mockito.invocation.InvocationFactory;
 import org.mockito.invocation.MockHandler;
diff --git a/src/test/java/org/mockito/internal/junit/ExceptionFactoryTest.java b/src/test/java/org/mockito/internal/junit/ExceptionFactoryTest.java
index a1e2564c5d..2c1037bae2 100644
--- a/src/test/java/org/mockito/internal/junit/ExceptionFactoryTest.java
+++ b/src/test/java/org/mockito/internal/junit/ExceptionFactoryTest.java
@@ -8,51 +8,95 @@
 import static org.mockitoutil.ClassLoaders.excludingClassLoader;
 
 import java.lang.reflect.Method;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.exceptions.verification.ArgumentsAreDifferent;
 
 public class ExceptionFactoryTest {
 
-    private static ClassLoader classLoaderWithoutJUnit = excludingClassLoader().withCodeSourceUrlOf(ExceptionFactory.class).without("org.junit", "junit").build();
+    private static ClassLoader classLoaderWithoutJUnitOrOpenTest = excludingClassLoader().withCodeSourceUrlOf(ExceptionFactory.class).without("org.junit", "junit", "org.opentest4j").build();
+    private static ClassLoader classLoaderWithoutOpenTest = excludingClassLoader().withCodeSourceUrlOf(ExceptionFactory.class, org.junit.ComparisonFailure.class).without("org.opentest4j").build();
+    private static ClassLoader currentClassLoader = ExceptionFactoryTest.class.getClassLoader();
+
+    /** loaded by the current classloader */
+    private static Class<?> opentestComparisonFailure;
+    private static Class<?> opentestArgumentsAreDifferent;
 
-    /** loaded by the current current class loader */
-    private static Class<?> junitArgumentsAreDifferent;
+    /** loaded by the classloader {@value #classLoaderWithoutOpenTest}, which excludes OpenTest4J classes */
+    private static Class<?> junit3ComparisonFailure;
+    private static Class<?> junit3ArgumentsAreDifferent;
 
-    /** loaded by the custom classloader {@value #classLoaderWithoutJUnit}, which excludes junit-classes */
+    /** loaded by the custom classloader {@value #classLoaderWithoutJUnitOrOpenTest}, which excludes JUnit and OpenTest4J classes */
     private static Class<?> nonJunitArgumentsAreDifferent;
 
     @BeforeClass
     public static void init() throws ClassNotFoundException {
-        nonJunitArgumentsAreDifferent = classLoaderWithoutJUnit.loadClass(ArgumentsAreDifferent.class.getName());
-        junitArgumentsAreDifferent = org.mockito.exceptions.verification.junit.ArgumentsAreDifferent.class;
+        nonJunitArgumentsAreDifferent = classLoaderWithoutJUnitOrOpenTest.loadClass(ArgumentsAreDifferent.class.getName());
+        junit3ComparisonFailure = classLoaderWithoutOpenTest.loadClass(junit.framework.ComparisonFailure.class.getName());
+        junit3ArgumentsAreDifferent = classLoaderWithoutOpenTest.loadClass(org.mockito.exceptions.verification.junit.ArgumentsAreDifferent.class.getName());
+        opentestComparisonFailure = org.opentest4j.AssertionFailedError.class;
+        opentestArgumentsAreDifferent = org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent.class;
     }
 
     @Test
-    public void createArgumentsAreDifferentException_withoutJUnit() throws Exception {
-        Class<?> exceptionFactory = classLoaderWithoutJUnit.loadClass(ExceptionFactory.class.getName());
+    public void createArgumentsAreDifferentException_withoutJUnitOrOpenTest() throws Exception {
+        AssertionError e = invokeFactoryThroughLoader(classLoaderWithoutJUnitOrOpenTest);
 
-        Method m = exceptionFactory.getDeclaredMethod("createArgumentsAreDifferentException", String.class, String.class, String.class);
-        Object e = m.invoke(null, "message", "wanted", "actual");
+        assertThat(e).isExactlyInstanceOf(nonJunitArgumentsAreDifferent);
+    }
+
+    @Test
+    public void createArgumentsAreDifferentException_withJUnit3_butNotOpenTest() throws Exception {
+        AssertionError e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
+
+        assertThat(e).isExactlyInstanceOf(junit3ArgumentsAreDifferent).isInstanceOf(junit3ComparisonFailure);
+    }
+
+    @Test
+    public void createArgumentsAreDifferentException_withOpenTest() throws Exception {
+        AssertionError e = invokeFactoryThroughLoader(currentClassLoader);
+
+        assertThat(e).isExactlyInstanceOf(opentestArgumentsAreDifferent).isInstanceOf(opentestComparisonFailure);
+    }
+
+    @Test
+    public void createArgumentsAreDifferentException_withoutJUnitOrOpenTest_2x() throws Exception {
+        AssertionError e;
+
+        e = invokeFactoryThroughLoader(classLoaderWithoutJUnitOrOpenTest);
+        assertThat(e).isExactlyInstanceOf(nonJunitArgumentsAreDifferent);
 
+        e = invokeFactoryThroughLoader(classLoaderWithoutJUnitOrOpenTest);
         assertThat(e).isExactlyInstanceOf(nonJunitArgumentsAreDifferent);
     }
 
     @Test
-    public void createArgumentsAreDifferentException_withJUnit() throws Exception {
-        AssertionError e = ExceptionFactory.createArgumentsAreDifferentException("message", "wanted", "actual");
+    public void createArgumentsAreDifferentException_withJUnit3_2x() throws Exception {
+        AssertionError e;
+
+        e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
+        assertThat(e).isExactlyInstanceOf(junit3ArgumentsAreDifferent);
 
-        assertThat(e).isExactlyInstanceOf(junitArgumentsAreDifferent);
+        e = invokeFactoryThroughLoader(classLoaderWithoutOpenTest);
+        assertThat(e).isExactlyInstanceOf(junit3ArgumentsAreDifferent);
     }
 
     @Test
-    public void createArgumentsAreDifferentException_withJUnit2x() throws Exception {
+    public void createArgumentsAreDifferentException_withOpenTest_2x() throws Exception {
         AssertionError e;
 
-        e = ExceptionFactory.createArgumentsAreDifferentException("message", "wanted", "actual");
-        assertThat(e).isExactlyInstanceOf(junitArgumentsAreDifferent);
+        e = invokeFactoryThroughLoader(currentClassLoader);
+        assertThat(e).isExactlyInstanceOf(opentestArgumentsAreDifferent);
+
+        e = invokeFactoryThroughLoader(currentClassLoader);
+        assertThat(e).isExactlyInstanceOf(opentestArgumentsAreDifferent);
+    }
+
+    private static AssertionError invokeFactoryThroughLoader(ClassLoader loader) throws Exception {
+        Class<?> exceptionFactory = loader.loadClass(ExceptionFactory.class.getName());
 
-        e = ExceptionFactory.createArgumentsAreDifferentException("message", "wanted", "actual");
-        assertThat(e).isExactlyInstanceOf(junitArgumentsAreDifferent);
+        Method m = exceptionFactory.getDeclaredMethod("createArgumentsAreDifferentException", String.class, String.class, String.class);
+        return (AssertionError) m.invoke(null, "message", "wanted", "actual");
     }
 }
diff --git a/src/test/java/org/mockito/internal/verification/VerificationOverTimeImplTest.java b/src/test/java/org/mockito/internal/verification/VerificationOverTimeImplTest.java
index e846216cbf..2e567427a2 100644
--- a/src/test/java/org/mockito/internal/verification/VerificationOverTimeImplTest.java
+++ b/src/test/java/org/mockito/internal/verification/VerificationOverTimeImplTest.java
@@ -10,7 +10,7 @@
 import org.junit.rules.ExpectedException;
 import org.mockito.Mock;
 import org.mockito.exceptions.base.MockitoAssertionError;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockito.verification.VerificationMode;
 
 import static org.hamcrest.CoreMatchers.is;
diff --git a/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationCheckerTest.java b/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationCheckerTest.java
index 4ce557ec66..15a57b96d6 100644
--- a/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationCheckerTest.java
+++ b/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationCheckerTest.java
@@ -13,7 +13,7 @@
 import org.junit.rules.ExpectedException;
 import org.mockito.Mock;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockito.internal.invocation.InvocationBuilder;
 import org.mockito.internal.invocation.InvocationMatcher;
 import org.mockito.invocation.Invocation;
diff --git a/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationInOrderCheckerTest.java b/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationInOrderCheckerTest.java
index 7f37b12d44..51cbc02c70 100644
--- a/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationInOrderCheckerTest.java
+++ b/src/test/java/org/mockito/internal/verification/checkers/MissingInvocationInOrderCheckerTest.java
@@ -12,7 +12,7 @@
 import org.mockito.Mock;
 import org.mockito.exceptions.verification.VerificationInOrderFailure;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockito.internal.invocation.InvocationBuilder;
 import org.mockito.internal.invocation.InvocationMatcher;
 import org.mockito.internal.verification.InOrderContextImpl;
diff --git a/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java b/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
index 90569a8117..85e0113589 100644
--- a/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
+++ b/src/test/java/org/mockitointegration/NoJUnitDependenciesTest.java
@@ -33,10 +33,10 @@ public void pure_mockito_should_not_depend_JUnit___ByteBuddy() throws Exception
                         Objenesis.class
                 )
                 .withCodeSourceUrlOf(coverageTool())
-                .without("junit", "org.junit")
+                .without("junit", "org.junit", "org.opentest4j")
                 .build();
 
-        Set<String> pureMockitoAPIClasses = ClassLoaders.in(classLoader_without_JUnit).omit("runners", "junit", "JUnit").listOwnedClasses();
+        Set<String> pureMockitoAPIClasses = ClassLoaders.in(classLoader_without_JUnit).omit("runners", "junit", "JUnit", "opentest4j").listOwnedClasses();
 
         // The later class is required to be initialized before any inline mock maker classes can be loaded.
         checkDependency(classLoader_without_JUnit, "org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker");
diff --git a/src/test/java/org/mockitousage/basicapi/UsingVarargsTest.java b/src/test/java/org/mockitousage/basicapi/UsingVarargsTest.java
index 3e4faaf923..c8f3dd5bdc 100644
--- a/src/test/java/org/mockitousage/basicapi/UsingVarargsTest.java
+++ b/src/test/java/org/mockitousage/basicapi/UsingVarargsTest.java
@@ -9,7 +9,7 @@
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.exceptions.verification.NoInteractionsWanted;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitoutil.TestBase;
 
 import java.util.ArrayList;
diff --git a/src/test/java/org/mockitousage/matchers/CustomMatcherDoesYieldCCETest.java b/src/test/java/org/mockitousage/matchers/CustomMatcherDoesYieldCCETest.java
index 3114834182..8c94d3d1f6 100644
--- a/src/test/java/org/mockitousage/matchers/CustomMatcherDoesYieldCCETest.java
+++ b/src/test/java/org/mockitousage/matchers/CustomMatcherDoesYieldCCETest.java
@@ -7,7 +7,7 @@
 import org.junit.Test;
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mock;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/matchers/HamcrestMatchersTest.java b/src/test/java/org/mockitousage/matchers/HamcrestMatchersTest.java
index bee9569bf5..4d6b868cf8 100644
--- a/src/test/java/org/mockitousage/matchers/HamcrestMatchersTest.java
+++ b/src/test/java/org/mockitousage/matchers/HamcrestMatchersTest.java
@@ -11,7 +11,7 @@
 import org.mockito.ArgumentMatcher;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/matchers/MatchersTest.java b/src/test/java/org/mockitousage/matchers/MatchersTest.java
index 51a227d215..d38e676e96 100644
--- a/src/test/java/org/mockitousage/matchers/MatchersTest.java
+++ b/src/test/java/org/mockitousage/matchers/MatchersTest.java
@@ -14,7 +14,7 @@
 import org.junit.Test;
 import org.mockito.Mockito;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/matchers/MoreMatchersTest.java b/src/test/java/org/mockitousage/matchers/MoreMatchersTest.java
index f446f57f5c..6c0f9c2dc3 100644
--- a/src/test/java/org/mockitousage/matchers/MoreMatchersTest.java
+++ b/src/test/java/org/mockitousage/matchers/MoreMatchersTest.java
@@ -9,7 +9,7 @@
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/matchers/ReflectionMatchersTest.java b/src/test/java/org/mockitousage/matchers/ReflectionMatchersTest.java
index 84ad482103..a972d0fbbb 100644
--- a/src/test/java/org/mockitousage/matchers/ReflectionMatchersTest.java
+++ b/src/test/java/org/mockitousage/matchers/ReflectionMatchersTest.java
@@ -7,7 +7,7 @@
 
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitoutil.TestBase;
 
 import static org.mockito.Matchers.refEq;
diff --git a/src/test/java/org/mockitousage/matchers/VarargsTest.java b/src/test/java/org/mockitousage/matchers/VarargsTest.java
index 685c918a12..1433919d72 100644
--- a/src/test/java/org/mockitousage/matchers/VarargsTest.java
+++ b/src/test/java/org/mockitousage/matchers/VarargsTest.java
@@ -23,7 +23,7 @@
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockito.junit.MockitoJUnit;
 import org.mockito.junit.MockitoRule;
 import org.mockitousage.IMethods;
diff --git a/src/test/java/org/mockitousage/stacktrace/ClickableStackTracesTest.java b/src/test/java/org/mockitousage/stacktrace/ClickableStackTracesTest.java
index 92e1e85ca9..029ea2fa99 100644
--- a/src/test/java/org/mockitousage/stacktrace/ClickableStackTracesTest.java
+++ b/src/test/java/org/mockitousage/stacktrace/ClickableStackTracesTest.java
@@ -7,7 +7,7 @@
 
 import org.junit.Test;
 import org.mockito.Mock;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/verification/BasicVerificationInOrderTest.java b/src/test/java/org/mockitousage/verification/BasicVerificationInOrderTest.java
index b0e31798e9..af422619d6 100644
--- a/src/test/java/org/mockitousage/verification/BasicVerificationInOrderTest.java
+++ b/src/test/java/org/mockitousage/verification/BasicVerificationInOrderTest.java
@@ -12,7 +12,7 @@
 import org.mockito.exceptions.verification.NoInteractionsWanted;
 import org.mockito.exceptions.verification.VerificationInOrderFailure;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/verification/BasicVerificationTest.java b/src/test/java/org/mockitousage/verification/BasicVerificationTest.java
index d9a74fff6e..3ede48b407 100644
--- a/src/test/java/org/mockitousage/verification/BasicVerificationTest.java
+++ b/src/test/java/org/mockitousage/verification/BasicVerificationTest.java
@@ -11,7 +11,7 @@
 import org.mockito.exceptions.verification.NoInteractionsWanted;
 import org.mockito.exceptions.verification.TooManyActualInvocations;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/verification/DescriptiveMessagesOnVerificationInOrderErrorsTest.java b/src/test/java/org/mockitousage/verification/DescriptiveMessagesOnVerificationInOrderErrorsTest.java
index 8e1bf06322..e920ad8f4e 100644
--- a/src/test/java/org/mockitousage/verification/DescriptiveMessagesOnVerificationInOrderErrorsTest.java
+++ b/src/test/java/org/mockitousage/verification/DescriptiveMessagesOnVerificationInOrderErrorsTest.java
@@ -96,7 +96,7 @@ public void shouldPrintVerificationInOrderErrorAndShowWantedAndActual() {
         try {
             inOrder.verify(one).simpleMethod(999);
             fail();
-        } catch (org.mockito.exceptions.verification.junit.ArgumentsAreDifferent e) {
+        } catch (org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent e) {
             assertThat(e).hasMessageContaining("has different arguments");
         }
     }
diff --git a/src/test/java/org/mockitousage/verification/DescriptiveMessagesWhenVerificationFailsTest.java b/src/test/java/org/mockitousage/verification/DescriptiveMessagesWhenVerificationFailsTest.java
index 43729f3107..729343471f 100644
--- a/src/test/java/org/mockitousage/verification/DescriptiveMessagesWhenVerificationFailsTest.java
+++ b/src/test/java/org/mockitousage/verification/DescriptiveMessagesWhenVerificationFailsTest.java
@@ -13,7 +13,7 @@
 import org.mockito.exceptions.verification.NeverWantedButInvoked;
 import org.mockito.exceptions.verification.NoInteractionsWanted;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/verification/PrintingVerboseTypesWithArgumentsTest.java b/src/test/java/org/mockitousage/verification/PrintingVerboseTypesWithArgumentsTest.java
index 954b99f16c..8456c46c52 100644
--- a/src/test/java/org/mockitousage/verification/PrintingVerboseTypesWithArgumentsTest.java
+++ b/src/test/java/org/mockitousage/verification/PrintingVerboseTypesWithArgumentsTest.java
@@ -7,7 +7,7 @@
 
 import org.assertj.core.api.Assertions;
 import org.junit.Test;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;
 
diff --git a/src/test/java/org/mockitousage/verification/VerificationUsingMatchersTest.java b/src/test/java/org/mockitousage/verification/VerificationUsingMatchersTest.java
index 027eb2cdbf..bfc2e2225f 100644
--- a/src/test/java/org/mockitousage/verification/VerificationUsingMatchersTest.java
+++ b/src/test/java/org/mockitousage/verification/VerificationUsingMatchersTest.java
@@ -10,7 +10,7 @@
 import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.mockito.exceptions.verification.WantedButNotInvoked;
-import org.mockito.exceptions.verification.junit.ArgumentsAreDifferent;
+import org.mockito.exceptions.verification.opentest4j.ArgumentsAreDifferent;
 import org.mockitousage.IMethods;
 import org.mockitoutil.TestBase;