File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: testing a private method with JUnit / Coverlipse
 
Similar Threads
K&B page 448 Question on GC
can the cause of memory leak be detected here?
hashcode and equals
Equals Method problem
Need some urgent help