Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I write a Junit test for my main method in the class

 
sandeep wagh
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do I write a Junit test for my main method in the class. It is the only method in the class and as usual returns void. I can't see any side effect also happenning here which will help me test the result.

Thanks,
Sandeep
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the main method does something, right? :-)

I'd restructure the code so that all the functional code moves out of the main method into instance methods that return meaningful results. So instead of


you'd have

 
sandeep wagh
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks A lot.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic