Closed GoogleCodeExporter closed 8 years ago
Hey,
Good tests, thanks!
This is not supported by Mockito. See the FAQ entry on multi-threading.
when/verify is not thread safe because if you do it in multiple threads it will
lead to non-deterministic results. However you can do when/verify outside of
concurrency but allow mocks to be simply called/used in concurrency. Makes
sense?
Original comment by szcze...@gmail.com
on 18 Jul 2010 at 1:40
Hi,
Fair enough, fixing the tests wasn't that hard. Although it took me a while to
understand the reason of the failure as it wasn't obvious from the error
message.
Maybe it's worth putting it into the FAQ? Something along the lines: if you
concurrently mock and use a shared mock (sorry for tautology) you *will* see
exceptions like org.mockito.exceptions.misusing.WrongTypeOfReturnValue or
java.util.ConcurrentModificationException.
Anyway, thanks for the wonderful library!
Original comment by ivankob...@gmail.com
on 19 Jul 2010 at 7:09
I like your idea, will update the FAQ.
Cheers!
Original comment by szcze...@gmail.com
on 19 Jul 2010 at 8:28
Updated FAQ and changed the code a bit so that ConcurrentModificationException
should not occur (that often :). It is still not supported but at least it is
better documented.
Original comment by szcze...@gmail.com
on 13 Aug 2010 at 9:02
Original comment by szcze...@gmail.com
on 3 Jul 2011 at 12:43
can we use synchronization here means we create an object
Object obj=new Object
and then use this like
synchronized (obj){
Object1.method1()
}
synchronized (obj){
Object1.method2()
}
Original comment by anil.goy...@gmail.com
on 22 May 2014 at 8:54
yes that should work. (if it's not about stubbing)
Original comment by brice.du...@gmail.com
on 27 Jun 2014 at 4:14
Original issue reported on code.google.com by
ivankob...@gmail.com
on 13 Jul 2010 at 7:16Attachments: