July 31st, 2012, 12:15 PM
Create a test class (main method) to start(run) the class in Java
Maybe I do not understand something.
So I've created the class in Java, which does some stuff.I need to create a main method or mainClass, that will start(run) my class. (I do not mean JUnit).
Question: how to do it?
is there some sort of methodology?
described in the books somewhere?
Help me please
July 31st, 2012, 12:28 PM
I usually just add a main() method to the class to be tested. In the main() method, create an instance of the class to be tested and depending on what that class's constructor does, you may need to call other methods in the class to start execution of the class.
To start execution: java <ClassNameWithMainMethod>
There must be lots of code examples here on this forum or on the net you can look at.
Last edited by NormR; July 31st, 2012 at 02:59 PM.
July 31st, 2012, 01:12 PM
July 31st, 2012, 03:05 PM
Cross posted at http://www.javaprogrammingforums.com/java-theory-questions/17031-create-test-class-main-method-start-run-class-java.html