From 6886b0f6a286622620ba3c6f875c215d25a79d4f Mon Sep 17 00:00:00 2001 From: saurabh7248 Date: Fri, 30 Jul 2021 10:55:31 +0530 Subject: [PATCH] Fixes #2331 Has conditionally on basis of whether default answer is pass to actual methods made hash code and equals pass to actual methods. Intellij seems to had only pushed import and not the test --- .../org/mockitousage/spies/SpyingOnRealObjectsTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/org/mockitousage/spies/SpyingOnRealObjectsTest.java b/src/test/java/org/mockitousage/spies/SpyingOnRealObjectsTest.java index 0511965720..06b4878fa3 100644 --- a/src/test/java/org/mockitousage/spies/SpyingOnRealObjectsTest.java +++ b/src/test/java/org/mockitousage/spies/SpyingOnRealObjectsTest.java @@ -193,4 +193,13 @@ public void shouldSayNiceMessageWhenSpyingOnPrivateClass() throws Exception { "Most likely it is due to mocking a private class that is not visible to Mockito"); } } + + @Test + public void spysHashCodeEqualsDelegatedToActualMethods() { + List real = new ArrayList<>(); + real.add("one"); + List spy = spy(real); + assertEquals(real.hashCode(), spy.hashCode()); + assertTrue(spy.equals(real)); + } }