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

Any JUnit Test Could be Written for

 
Natalie Kopple
Ranch Hand
Posts: 325
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think no..Let see what other can say...
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11865
194
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic