Tuesday, October 13, 2015

Make JUnit as executable jar file

Creating executable jar file from eclipse for JUnit.
Here the JUnit file is "YRover1.java".














We need to create a main class for this program, which will in turn run the JUnit file I have it as "TryMain.txt".
We need to include library "import org.junit.runner.JUnitCore;"









and include the JUnit file as "JUnitCore.main("googletry.YRover1");" inside the main function.
"googletry" is the name of the package"

Then , select the project name and right click - > Run as -> Run configurations








Here we need to mention the Main class of the project. The name of the run configuration can be given (be it unique). Click on run if need to test it with main class handling the JUnit.
Then right click on the project -> Export ->Java->Runnable JAR file and click Next


















In Launch configuration, select the Run configuration which we had created earlier,
Specify the destination and select the option , if you want the supporting libraries to be included or to be copied as a separate folder.
Also an ANT script can be generated with this. Click Finish.
That's, it, the exported JAR file will now be an standalone executable file.