aspose file tools*
The moose likes Testing and the fly likes Any JUnit Test Could be Written for Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Any JUnit Test Could be Written for" Watch "Any JUnit Test Could be Written for" New topic
Author

Any JUnit Test Could be Written for

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Hi, thank you first for reading my post.

I have a very simple "marshaller" class (see below). I wonder if any JUnit test could be written for it. Would you please suggest if there is any?
Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

i think no..Let see what other can say...


SCJP6.0,My blog Ranchers from Delhi
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11481
    
  94

Possibly not based on the way the code is written, however it would be easy enough to rewrite it to support test cases.

The question I would have, though, is what are you trying to test? The code you have provided is basically marshaling a bean. You should not really need to unit test your beans or third-party libraries. Take those two out of the equation, and you have almost nothing to test.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Why can't a JUnit test be written? You call the method and then read the file on the file system to see if the results are what you expected.

If you are talking about a pure unit test without the file system, you'd need to refactor.


[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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Any JUnit Test Could be Written for