Skip to content

Commit

Permalink
Add suspension when Mockito exception is thrown.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Aug 24, 2020
1 parent 065dd12 commit eaa12bf
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,18 @@ public InlineByteBuddyMockMaker() {
} else if (type.isInstance(spy)) {
return spy;
} else {
// Unexpected construction of non-spied object
throw new MockitoException(
"Unexpected spy for "
+ type.getName()
+ " on instance of "
+ object.getClass().getName());
isSuspended.set(true);
try {
// Unexpected construction of non-spied object
throw new MockitoException(
"Unexpected spy for "
+ type.getName()
+ " on instance of "
+ object.getClass().getName(),
object instanceof Throwable ? (Throwable) object : null);
} finally {
isSuspended.set(false);
}
}
} else if (currentConstruction.get() != type) {
return null;
Expand Down

0 comments on commit eaa12bf

Please sign in to comment.