This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Testing and the fly likes How do I write a Junit test for my main method in the class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How do I write a Junit test for my main method in the class" Watch "How do I write a Junit test for my main method in the class" New topic
Author

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

sandeep wagh
Greenhorn

Joined: Aug 01, 2007
Posts: 9
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

Joined: Mar 22, 2005
Posts: 42958
    
  73
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

Joined: Aug 01, 2007
Posts: 9
Thanks A lot.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How do I write a Junit test for my main method in the class
 
It's not a secret anymore!