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 in the Outline view and select [run with arguments..]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 Casewithin Eclipse. In the wizard, you can indicate the class that provides yourstaticmethod in theClass 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…