Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jigar Gosar
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break the method into two as shown, then test the non-public one using data in a StringReader:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic