aspose file tools*
The moose likes Testing and the fly likes how to test functions who use java io classes like LineNumberReader and FileReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "how to test functions who use java io classes like LineNumberReader and FileReader" Watch "how to test functions who use java io classes like LineNumberReader and FileReader" New topic
Author

how to test functions who use java io classes like LineNumberReader and FileReader

Jigar Gosar
Ranch Hand

Joined: Jul 09, 2002
Posts: 95
I have following method in my class, I was wondering how could i write a unit test for a method that does file io, and uses java io classes such as FileReader, and LineNumberReader. I did some googling on "junit java io" "junit testing LineNumberReader" but didnot find anything useful.

Any help is appreciated.


[ March 09, 2006: Message edited by: Jigar Gosar ]

Regards,<br />Jigar Gosar (SCJP 1.4)<br />visit: <a href="http://jigar.org/blog" target="_blank" rel="nofollow">http://jigar.org/blog</a>
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Break the method into two as shown, then test the non-public one using data in a StringReader:



[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to test functions who use java io classes like LineNumberReader and FileReader
 
Similar Threads
this code is giving file not found exception
reading a file by lines
reading a file by lines
programatic diff tool
declaring array of vectors