• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not sure how to go about these tests, JUnit

 
Tom Mordon
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I'm a beginner with JUnit and am somewhat stumped on how to go about testing these large methods. Looking for input as to how I should go about attacking these methods. Pasted first are the three methods I'm trying to crack and below that are the JUnit test methods that came up. So far I've only had fairly simple methods that I have had to test so these have thrown me off a bit. Any input is appreciated. Thanks much!



 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34851
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tom,
You can test the code by reading in the hard coded file, but that's hard. It would be better to pass in the filename so you could use a test file. Or pass in a Reader, so you can pass in a StringReader and not have to deal with files at all.

IN terms of going one step further, you read test method needs to instantiate d. It also needs an assert.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic