wood burning stoves 2.0*
The moose likes Testing and the fly likes How to write junit tests for a method which has LoggingEvent  object type as argument Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to write junit tests for a method which has LoggingEvent  object type as argument" Watch "How to write junit tests for a method which has LoggingEvent  object type as argument" New topic
Author

How to write junit tests for a method which has LoggingEvent object type as argument

Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
Hi,

I have a Method (see below):



Now i need to write a junit test for this, but I am not sure WHERE to start?
1. Should i create a NEW instance of the class this method belongs to? first.
2. How do i get an "inEvent" of type LoggingEvent?
3. So this is how i start writing test case for the method:



Since WmLoggerFilter is the class that contains testdecide()

I would appreciate any help.

Thanks,
-Kamal.
Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
P.S:

Should i create a Logger, adn then attach an Appender to it, and then do a


and the test message would serve as object of type LoggingEvent?
But "test message" is a String
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to write junit tests for a method which has LoggingEvent object type as argument
 
Similar Threads
junit test for set Method with boolean input and void return
unit test for decide(LoggingEvent inEvent), throws an exception
junit test for log4j Filter method
getting thread names
junit - basics