This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Testing and the fly likes testing a private method with JUnit / Coverlipse 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 "testing a private method with JUnit / Coverlipse" Watch "testing a private method with JUnit / Coverlipse" New topic
Author

testing a private method with JUnit / Coverlipse

Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
I am testing the method:

And since it is private, used call hierarchy to find out that public void setConsoleAppending(boolean append, int outputType) calls this method.

Now in

if (!isSameOutputType(outputType, currentCA)) {
getLog4jLogger().removeAppender(name);

and if I make isSameOutputType(outputType, currentCA)) false, I can verify that :

the Appender is removed.

Now:
In order to make isSameOutPutType() false,
I force the return be false in:

String currCAOutputType = currentCA.getTarget();
return currCAOutputType.equals(ConsoleAppender.SYSTEM_OUT)

Here is my test method:


But, somehow, I am not getting the method isSameOutPutType() covered by coverlipse.

Could anyone please give me a hint?

Thanks,
-Kamal.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: testing a private method with JUnit / Coverlipse
 
Similar Threads
Need some urgent help
Equals Method problem
K&B page 448 Question on GC
hashcode and equals
can the cause of memory leak be detected here?