Is Mockito thread-safe?

4,103 views
Skip to first unread message

CowOfDoom

unread,
Sep 14, 2008, 7:34:24 PM9/14/08
to mockito
I'm interested in replacing my EasyMock with Mockito. I think that
it's a really promising library. Pretty much the only things holding
me back are that 1.) I can't find any documentation mentioning whether
or not Mockito can handle a heavily multi-threaded program, and 2.) it
appears that there's no Eclipse integration as of yet.

I can live without being able to run tests test by test in Eclipse,
but if I can't test any of my multi-threaded classes, I can't use it.
Does Mockito support MT apps?

szczepiq

unread,
Sep 15, 2008, 3:59:02 AM9/15/08
to moc...@googlegroups.com
Hi,

1. About multi-threading. Let's put it this way: Mockito is
thread-safe so long you don't do weird stuff... I put an explanation
in the FAQ: http://code.google.com/p/mockito/wiki/FAQ . Let me know if
you have more questions about it.

2. About eclipse integration. JUnit/TestNG is integrated with Eclipse.
Mockito integrates well with JUnit/TestNG. Therefore Mockito
integrates with Eclipse ;) Let me know what sort of integration you
have in mind. Mockito is just a java library - it plays nicely with
any other java library.

Cheers,
Szczepan Faber

szczepiq

unread,
Sep 15, 2008, 4:02:31 AM9/15/08
to moc...@googlegroups.com
One more thing. If you're unsure about Mockito's thread-safety, check
out the Mockito source code (
http://code.google.com/p/mockito/source/checkout ) and play with tests
from org.concurrentmockito package.

Hope that helps.
Szczepan Faber

On Mon, Sep 15, 2008 at 1:34 AM, CowOfDoom <bran...@gmail.com> wrote:
>

CowOfDoom

unread,
Sep 15, 2008, 1:12:20 PM9/15/08
to mockito
That is most excellent! Somehow I completely overlooked that bit in
the FAQ. Supporting concurrency in the testing but not in the
stubbing and verifying seems like exactly the appropriate amount of
concurrency support. Thanks very much :)

Also, apparently my brain exploded about halfway into my post and
confused unit testing tools with mock libraries :) I hate it when
that happens...

On 15 Sep, 00:59, szczepiq <szcze...@gmail.com> wrote:
> Hi,
>
> 1. About multi-threading. Let's put it this way: Mockito is
> thread-safe so long you don't do weird stuff... I put an explanation
> in the FAQ:http://code.google.com/p/mockito/wiki/FAQ. Let me know if
> you have more questions about it.
>
> 2. About eclipse integration. JUnit/TestNG is integrated with Eclipse.
> Mockito integrates well with JUnit/TestNG. Therefore Mockito
> integrates with Eclipse ;) Let me know what sort of integration you
> have in mind. Mockito is just a java library - it plays nicely with
> any other java library.
>
> Cheers,
> Szczepan Faber
>
Reply all
Reply to author
Forward
0 new messages