File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Dependency Injection & Testability Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Dependency Injection & Testability" Watch "Dependency Injection & Testability" New topic
Author

Dependency Injection & Testability

shanthi naidu
Ranch Hand

Joined: Nov 13, 2008
Posts: 39
Hi all,

Dependency injection is simply a good idea and it helps with: testability


Please can anyone tell me how dependency injection helps with testability

Thanks,
Shanthi Naidu
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Well, let's start this way--what's your understanding of what dependency injection is? Can you think of any reasons it might make testing easier?
shanthi naidu
Ranch Hand

Joined: Nov 13, 2008
Posts: 39
well with dependency injection we can inject the mock objects first till we get the required output and then inject the original objects ... in this way testing became flexible with dependency injection??
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's probably the biggest testing advantage, yes--it allows us to choose what exactly to test.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dependency Injection & Testability