This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

Not sure how to go about these tests, JUnit

Tom Mordon
Ranch Hand

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

Joined: May 26, 2003
Posts: 32481

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Have you checked out Aspose?
subject: Not sure how to go about these tests, JUnit
It's not a secret anymore!