Using Junit coverage, it can't cover public static void main method. How can I cover it?
After making sure it's testable just call it as any other public static method:
YourClass.main(new String[] {"parameter 1", "parameter 2"});
And assert the following state afterwards.
Because it does not return anything, you cannot check the output. But what does it do? If it calls another method the write a test for that method. If it doesn't call other methods, then write a test for that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.