Debug and Run your tests!

From here it is a matter of testing your test code and running it against your target board. You can also make a stand alone “runner” ... that will enable you to do testing of your unit under test outside of the Eclipse environment.

We need to enter the “debug perspective” and then launch (and use) a debug session

Enter the debug perspective by choosing “Window” → “Open Perspective” → “Debug”

Click on the down arrow next to the Debug Icon () on the tool bar and select “Debug Configurations...”

The only tab you need to modify is “Test” ... the others can stay with the default values.

 


Creating a Junit 4 Test Runner session and JAR file


Once a series of tests has been debugged they can be exported into a stand along JAR file that can be run outside the Eclipse environment.

Click on the arrow next to the Run Icon and select Run Configurations...

In the Run Configurations dialog double click Java Application to bring up its tabbed windows. Type "RunAsJarFile" after Name and leave all the other tabbed windows to their defaults. Click the Apply button to save. Now either clicking the debug button in this window or simply clicking the Run icon in the Java Browsing perspective will start the tests running.

Click the Run icon, the Console view should now show the output of the TestRunner as it runs main() in src\BoardTest\<Board>.java which invokes the TestRunner class to run the tests the <Board> class contains.

In the Java Browser : Project Explorer view highlight <Board>_JunitBoardTest. Then select File → Export.


In the Export dialog that appears select Java - Runnable JAR File and click Next.

In the Runnable Jar File Export dialog, select Launch Configuration : RunAsJarFile - <Board>_JunitBoardTest (created in step 3) Export Destination : (use the browse button to select it's name, typically <Board>_BT.jar, and where to put jar file) Then click Finish.

In the Runnable JAR File Export popup window stating that it will be repacking referenced libraries (junit-5.5.jar and MacraigorApi.jar) click the OK button. The jar file then gets created.

To run the JAR file open a msdos command or linux shell window, your current PATH environmental variable should include c:\cygwin\usr\local\bin (WINDOWS) or /usr/local/bin (LINUX). "Cd"-ing to the directory containing the JAR file and entering : RunJarFileAndWait <Board>_BT.jar will run the application's test runner.