--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
Hey Sjaak,
The problem comes down to an incompatibility between JUnit and Hamcrest
version 1.2 and above[1]. JUnit uses the default toString() whereas Hamcrest
uses the describeMismatch() when tests make calls to:
org.hamcrest.MatcherAssert.assertThat()
rather than:
org.junit.Assert.assertThat()
The TypeSafeDiagnosingMatcher you mention is also available only with Hamcrest
version 1.2 and above.
JUnit is currently not planning to upgrade above Hamcrest 1.1 because of
incompatibility in method signatures, mostly related to generics bounds. Maybe
Szczepan could tell us if Mockito is subject to the same conditions?
If Mockito has the same compatibility issue as JUnit, I don't see there being
an easy solution, I'm afraid :-(
HTH,
Graham
[1] http://stackoverflow.com/questions/3915635/is-there-a-version-of-junit-
assertthat-which-uses-the-hamcrest-describemismatch
The only thing that springs to mind is to wrap the type you have no control
over with something of your own that delegates every call to the real
instance. Then you could implement whatever toString() you want.
That does have downsides, such as a lot of boilerplate, and instanceof won't
work, but it has its benefits as well, like decoupling from 3rd party
dependencies. See also the advice "don't mock types you don't own".
Sorry I couldn't be of more help.
~ Graham
--
You received this message because you are subscribed to the Google Groups "mockito" group.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.