File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Testing and the fly likes Singletons and testing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Singletons and testing" Watch "Singletons and testing" New topic

Singletons and testing

Pepe Papa

Joined: Jul 26, 2007
Posts: 3
i'd like to know if there is any problem with programatic Singletons at test time, which are them?

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336


Please check your private messages.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

It depends. If you want to mock out a class, a singleton makes things much harder than necessary.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Vilmantas Baranauskas
Ranch Hand

Joined: Dec 20, 2006
Posts: 89
Quite interesting article about singletons:

Author of <a href="" target="_blank" rel="nofollow">NewsInjector</a>
I agree. Here's the link:
subject: Singletons and testing
It's not a secret anymore!