Java Mocking Frameworks Comparison

I found a very nice comparison of mocking frameworks for Java/JVM. If you already have a basic understanding about mocking and are looking for a good framework with easy to learn syntax this site will definitely be helpful.

However my favourite is Mockito, which comes with a very intuitive syntax and allows mocking by stub methods. Let’s say you have a class Foobar with a public method int callMe(String s) to stub the method use the following code:

Foobar mockedFoobar = mock(Foobar.class);

That’s all, just two lines of code and you successfully mocked a method without complicated inheritance strategies :)

2 Responses to “Java Mocking Frameworks Comparison”

  1. 1 waywalker1 August 6, 2009 at 9:33 pm

    Some new thing in java programming world: Domain Driven frameworks.

  2. 2 Adarsh Thimmappa March 13, 2012 at 8:07 am

    Try JMockit and let me know. And, it’s much more powerful too. It purely depends on what all things you are looking for from mocking perspective. Anyways, happy mocking.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: