Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2008

Tip: Looking for answers? Try searching our database.

Testing your logging (best practices)

Thread view: 
Hoss Spence - 07 Feb 2008 22:44 GMT
Curious how many test their logging statements here. To test that my
logging  is what I expect it to be I usually create an instance
variable e.g. mLogMessage. I set it and log it, then check my
mLogMessage in my Junit test. This allows me to test what I'd expect
my log to be without checking the log file itself. The negative is
that I have a getLogMessage() which is only used by Junit. Wondered
what other approaches people use.
Roger Lindsjö - 09 Feb 2008 13:53 GMT
> Curious how many test their logging statements here. To test that my
> logging  is what I expect it to be I usually create an instance
[quoted text clipped - 3 lines]
> that I have a getLogMessage() which is only used by Junit. Wondered
> what other approaches people use.

What logging framework are you using. You could probably create your own
log listener / handler (or whatever they are called in your framework)
which gives you access to logged messages from withing you unit test.

--
Roger Lindsjö


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.