IoC and Unit Testing

1 AM December 6, 2004

We’re using Spring at work, and getting major benefits in our unit testing. We are testing more code, and more thoroughly than on any Java project I’ve been involved with before now. I was going to write something about how Inversion of Control frameworks like Spring provide these benefits, but then I found this:

Large applications can prove troublesome to unit test exhaustively, especially if there is any kind of tight coupling between components. Such coupling of components can make it difficult to test them separately.

Needle [an Inversion of Control framework for Ruby] ... encourages loose coupling of components. Also, because dependencies are never instantiated in code, but are instead accepted via setters or constructor arguments, it is trivial to replace those dependencies with mock objects at unit test time.

(That’s from the Needle Manual. Needle is an Inversion of Control framework for Ruby.)

By alang | # | Comments (1)
(Posted to javablogs, Software Development and Java)

Comments

At 15:43, 06 Dec 2004 Mike Shoemaker wrote:

I put together a sample app that shows how using spring allows easier unit testing. Have a look http://www.shoesobjects.com/blog/2004/11/21/1101083542880.html

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green