java.lang.VerifyError with Mockito 1.10.17

167 views
Skip to first unread message

Wim Deblauwe

unread,
Dec 31, 2014, 10:54:01 AM12/31/14
to moc...@googlegroups.com
Hi,

I am getting java.lang.VerifyError with Mockito 1.10.17 when I want to use 'timeout()'. See http://stackoverflow.com/questions/27721621/java-lang-verifyerror-with-mockito-1-10-17 for the question.

regards,

Wim

Szczepan Faber

unread,
Dec 31, 2014, 1:02:25 PM12/31/14
to moc...@googlegroups.com
Can you reproduce it in a small sample project or in Mockito test codebase?

Cheers!
> --
> You received this message because you are subscribed to the Google Groups
> "mockito" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mockito+u...@googlegroups.com.
> To post to this group, send email to moc...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mockito.
> For more options, visit https://groups.google.com/d/optout.



--
Szczepan Faber
Core dev@gradle; Founder@mockito

Wim Deblauwe

unread,
Jan 2, 2015, 5:53:25 AM1/2/15
to moc...@googlegroups.com
Yes.

I have create a sample project here: https://github.com/wimdeblauwe/mockito-verify-problem

regards,

Wim

Op woensdag 31 december 2014 19:02:25 UTC+1 schreef szczepiq:

Brice Dutheil

unread,
Jan 2, 2015, 8:06:32 AM1/2/15
to moc...@googlegroups.com

Hi,

tl;tr

We have an issue in the code internally the verification mode you are using use a JUnit class, that is not on the classpath. => Adding JUnit in the dependency of your POM will fix things.

Thanks for reporting. I’ve created an issue on GitHub (#152)

long story

For some reason TestNG 5.xxx make the JVM fail with a VerifyError, on a method that is not even called at that point.

java.lang.VerifyError: (class: org/mockito/internal/verification/VerificationOverTimeImpl, method: verify signature: 
   (Lorg/mockito/internal/verification/api/VerificationData;)V) Incompatible argument to function

But switching to the latest version of TestNG, 6.8.something make the JVM fail with the real cause : NoClassDefFoundError

java.lang.NoClassDefFoundError: junit/framework/ComparisonFailure

Which is the real issue here, now there’s only to find which class depends on JUnit. This class is ArgumentsAreDifferent which extends ComparisonFailure, this exception appears in a try/catch block in VerificationOverTimeImpl that is needed for the timeout verification.

This issue has been there probably since 1.10.x when fixing some timeout issues.

Note I copied this answer on SO as well.


-- Brice

Brice Dutheil

unread,
Jan 2, 2015, 9:01:32 AM1/2/15
to moc...@googlegroups.com
Note that it also reveal that mockito is not anymore compatible with JUnit 3.x.

-- Brice

Szczepan Faber

unread,
Jan 2, 2015, 9:20:12 AM1/2/15
to moc...@googlegroups.com
Wow Brice, great investigation, thanks!

Brice Dutheil

unread,
Jan 2, 2015, 9:29:59 AM1/2/15
to moc...@googlegroups.com
:)

However in my first mail there's an issue, I've used TestNG 6.x which do not have anymore JUnit as a transitive dependency. So this statement is only true with TestNG 6.x

> We have an issue in the code internally the verification mode you are using use a JUnit class, that is not on the classpath.

With TestNG 5.x JUnit 3.x is a transitive dependency, and the JVM cannot perform the linking, hence the VerifyError. Probably because `ComparisonFailure` differ enough between JUnit 3.x and 4.x to be incompatible for the JVM, even if it doesn't appear so source wise.

More info is in the ticket anyway.



-- Brice

Szczepan Faber

unread,
Jan 2, 2015, 9:34:38 AM1/2/15
to moc...@googlegroups.com
Thanks!

st.f...@gmail.com

unread,
Jan 2, 2015, 10:19:26 AM1/2/15
to moc...@googlegroups.com
Hi,

I wrote the answer for Wim's problem on StackOverflow. The first version of my answer was wrong and Brice pointed me into the correct direction. The cause of the VerifyError was a change in the class hierarchy of ComparisonFailure from JUnit 3.8.1 to 4.x. Since version 4.0 the base class is AssertionError and not Error anymore. When using JUnit 3.8.1 the VerifyError is caused because VerificationOverTimeImpl#handleVerificationError() expects an AssertionError as argument but would get the wrong type since AssertionError is not in the class hierarchy of ArgumentsAreDifferent.

So to be compatible with JUnit 3.x it would be sufficient to change the argument and return type of VerificationOverTimeImpl#handleVerificationError() from AssertionError to Error.


Cheers,
Stefan
Reply all
Reply to author
Forward
0 new messages