Thursday, September 18, 2008

Code coverage tool for UI

I was looking for a code coverage tool for Java based UI, I came across this tool – ECLEmma.

EclEmma is a free Java code coverage tool for Eclipse, available under the Eclipse Public License.

home page : http://www.eclemma.org/

Below are the steps that are to be followed to setup EclEmma for code coverage:

  1. Open Eclipse; Goto "Help->Software Updates->Find and Install" menu
  2. Click "Next >" In Install window and add a new remote site by clicking on "New Remote Site" button
  3. Enter any name and specify the URL as http://update.eclemma.org
  4. Click finish to search and install the EclEmma Java Code Coverage plug-in
  5. Restart Eclipse when prompted
  6. Now a new icon can be seen next to Run or Debug icons.

  1. Click on arrow next to Coverage icon and select "Open Coverage Dialog"
  2. Select “Eclipse Application” and click on “New” to create a new configuration.
  3. Goto "Coverage" tag and select only the packages in which the source for your feature is checked-in. You can contact the developer or see the folders in changelists to know the list of all packages used by the feature.
  4. Click on "Apply" after all the required packages are selected and then on "Coverage" button to launch your app in "Code Coverage" mode.
  5. Conduct Manual / Automated testing to cover the feature that you are trying to test and close your app.
  6. Now you can see a new tab with the name "Coverage" near "Console" or "Problems" tab
  7. Navigate to exact Java files where the source of your feature is written and check out the percentage of coverage done.
  8. You can double-click on Class or Function to navigate to corresponding Java file and see what parts of code were not exercised and write more test cases to cover the un-exercised code.
  9. You can export the whole of Coverage results to HTML format by right-clicking on any row and selecting "Export Session"
  10. You can have multiple sessions and then you can merge them together.