Is there an easy way to start a static function (not main) of a class in a few clicks in Eclipse?
Can do it in main function, but is there another way?
E.g. right click on a needed function开发者_Python百科 in the Outline view and select [run with arguments..]
A static method cannot be run, except of course if this method is the main(String... args)
method.
However, consider creating a JUnit test case for this method instead.
Create a JUnit Test Case
within Eclipse. In the wizard, you can indicate the class that provides your static
method in the Class under test:
field. Then Eclipse will give you the ability to create one test method per existing method on the class under test.
Once your JUnit test is created, simply right-click on this Java class and select Run as > JUnit test
. The shortcut is Alt+Shift+X, then T.
You can also consider doing some Test Driven Development...
Create a JUnit Test class for your static methods. Once created, it's only one click to test your static methods.
精彩评论