aspose file tools*
The moose likes Testing and the fly likes Not sure how to go about these tests, JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Not sure how to go about these tests, JUnit" Watch "Not sure how to go about these tests, JUnit" New topic
Author

Not sure how to go about these tests, JUnit

Tom Mordon
Ranch Hand

Joined: Apr 26, 2012
Posts: 30
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30548
    
152

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not sure how to go about these tests, JUnit