BIRT 3.7
Written by: Michael Williams
Featured Refcardz: Top Refcardz:
  1. Scrum
  2. Apache Maven 2
  3. Essential MySQL
  4. Node.js
  5. Groovy
  1. jQuery Selectors
  2. Ajax
  3. Java
  4. Spring Config.
  5. Java Concurrency

Link Details

Link 191518 thumbnail
User 294979 avatar

By cwash
via cwash.org
Published: Jun 10 2009 / 11:45

A quick introduction and example to using JMockit to mock dependencies.
  • 10
  • 0
  • 2672
  • 5

Comments

Add your comment
User 421478 avatar

psilokan replied ago:

0 votes Vote down Vote up Reply

Heh, the infamous pixeled theme

User 388907 avatar

MCII replied ago:

0 votes Vote down Vote up Reply

Argh! Static block in anonymous class. The example is really ugly.

User 294979 avatar

cwash replied ago:

0 votes Vote down Vote up Reply

@psilokan - yes, pixelated -- good eye! been using it for a while now...

@MCII - The JMockit code looks a lot different than what most people with a strong mocking background are used to seeing, but I think the way it works is more in tune with Java programming idioms. The static block is how you work with the expectations API. It's grown on me a bit, though.

You see the double chicken-lips in other forms. I personally prefer the static block to defining some type of anonymous inner class and having to implement interface methods.

I also don't mind the way this looks/works over all. Typically I don't want to define Expectations or "overridden behavior" for a period longer than the test method, anyway. The mocks can get reused, but what you're expecting on the mock is specific to a particular test method. I'm actually more comfortable never assigning them to a variable!
,

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (10)



Voters Against This Link (0)