Relax: You Can (Mostly) Stop Using Java Interfaces For Testing

Discussions

News: Relax: You Can (Mostly) Stop Using Java Interfaces For Testing

  1. Are you tired of turning every non-trivial class into an interface, and then create an "Impl" that actually does the work when mocking objects for testing? Do you know about JMock's ClassImposterizer? It allows you to mock instances without calling the constructor of the mocked class, ultimately helping you write and test your code faster. George Armhold writes:
    It's really hard to overstate the significance of this. It's changed the way I write and test code. It's very refreshing to be able to start out with a concrete class and write code that does stuff, rather than code that merely talks about doing stuff.
    JMock can be used for striking a balance between an accurate specification of a unit's required behavior and a flexible test that allows easy evolution of the code base.
  2. Or you could just use jmockit...
  3. Or you could just use Mockito...
  4. or you could use easymock + the class extension. It's been around for years. How is this news?
  5. I prefer the Unitils http://unitils.com/ mock testing framework.
  6. Hi,[ Go to top ]

    You got a really useful blog I have been here reading for about an hour. pass4sure E20-591 Useful information like this one must be kept and maintained so I will put this one on my bookmark list! pass4sure 642-832 Thanks for this wonderful post and hoping to post more of this blog here. pass4sure 642-437 I am a newbie and your success is very much an inspiration for me.