From 3f9ea84ad056376dee9ad7cee2a46e9fa8cfdb69 Mon Sep 17 00:00:00 2001 From: dstango Date: Sun, 26 Jun 2022 00:03:52 +0200 Subject: [PATCH] Clarify mocking error message and point to GitHub (#2693) Fixes #2692 --- .../ByteBuddyCrossClassLoaderSerializationSupport.java | 4 ++-- .../creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java | 2 +- .../creation/bytebuddy/SubclassByteBuddyMockMaker.java | 5 +++-- .../java/org/mockito/internal/runners/RunnerFactory.java | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/ByteBuddyCrossClassLoaderSerializationSupport.java b/src/main/java/org/mockito/internal/creation/bytebuddy/ByteBuddyCrossClassLoaderSerializationSupport.java index 02e8961385..a1eed21e77 100644 --- a/src/main/java/org/mockito/internal/creation/bytebuddy/ByteBuddyCrossClassLoaderSerializationSupport.java +++ b/src/main/java/org/mockito/internal/creation/bytebuddy/ByteBuddyCrossClassLoaderSerializationSupport.java @@ -219,14 +219,14 @@ private Object readResolve() throws ObjectStreamException { + typeToMock.getCanonicalName() + "'. The error was :", " " + ioe.getMessage(), - "If you are unsure what is the reason of this exception, feel free to contact us on the mailing list."), + "If you are unsure what is the reason of this exception, feel free to open an issue on GitHub."), ioe); } catch (ClassNotFoundException cce) { throw new MockitoSerializationIssue( join( "A class couldn't be found while deserializing a Mockito mock, you should check your classpath. The error was :", " " + cce.getMessage(), - "If you are still unsure what is the reason of this exception, feel free to contact us on the mailing list."), + "If you are still unsure what is the reason of this exception, feel free to open an issue on GitHub."), cce); } } diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java index bf6cf4b735..4c8c3fadd7 100644 --- a/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java +++ b/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java @@ -434,7 +434,7 @@ private RuntimeException prettifyFailure( join( "Mockito cannot mock this class: " + mockFeatures.getTypeToMock() + ".", "", - "If you're not sure why you're getting this error, please report to the mailing list.", + "If you're not sure why you're getting this error, please open an issue on GitHub.", "", Platform.warnForVM( "IBM J9 VM", diff --git a/src/main/java/org/mockito/internal/creation/bytebuddy/SubclassByteBuddyMockMaker.java b/src/main/java/org/mockito/internal/creation/bytebuddy/SubclassByteBuddyMockMaker.java index da8de10de9..e8dcce229a 100644 --- a/src/main/java/org/mockito/internal/creation/bytebuddy/SubclassByteBuddyMockMaker.java +++ b/src/main/java/org/mockito/internal/creation/bytebuddy/SubclassByteBuddyMockMaker.java @@ -114,8 +114,9 @@ private RuntimeException prettifyFailure( join( "Mockito cannot mock this class: " + mockFeatures.getTypeToMock() + ".", "", - "Mockito can only mock non-private & non-final classes.", - "If you're not sure why you're getting this error, please report to the mailing list.", + "Mockito can only mock non-private & non-final classes, but the root cause of this error might be different.", + "Please check the full stacktrace to understand what the issue is.", + "If you're still not sure why you're getting this error, please open an issue on GitHub.", "", Platform.warnForVM( "IBM J9 VM", diff --git a/src/main/java/org/mockito/internal/runners/RunnerFactory.java b/src/main/java/org/mockito/internal/runners/RunnerFactory.java index 369dc8ba82..68ef16cd1a 100644 --- a/src/main/java/org/mockito/internal/runners/RunnerFactory.java +++ b/src/main/java/org/mockito/internal/runners/RunnerFactory.java @@ -93,7 +93,7 @@ public InternalRunner create(Class klass, Supplier liste + "MockitoRunner can only be used with JUnit 4.5 or higher.\n" + "You can upgrade your JUnit version or write your own Runner (please consider contributing your runner to the Mockito community).\n" + "Bear in mind that you can still enjoy all features of the framework without using runners (they are completely optional).\n" - + "If you get this error despite using JUnit 4.5 or higher then please report this error to the mockito mailing list.\n", + + "If you get this error despite using JUnit 4.5 or higher, then please open an issue on GitHub.\n", t); } }