Laurie Williams, Ben Smith and Sarah Heckman
[Contact Authors] |
| 1.0 | Introduction to EclEmma |
| 2.0 | Running EclEmma |
| 3.0 | EclEmma Coverage Report |
| 4.0 | Exporting a Coverage Report |
| 5.0 | Exercise |
| 6.0 | Resources |
EclEmma is an Eclipse plug-in that generates code coverage reports and provide simple trace information about test cases. We will be using EclEmma primarily as a coverage reporting tool. Coverage is defined as a measure of the completeness of the set of test cases. This definition means that the more source code that is executed by your test cases the better. There are four types of coverage: There are four types of coverage:
For small programs, coverage is relatively easy to calculate by hand; however, for larger programs, the task is much more difficult. Coverage tools, like EclEmma, help by automating the coverage process and providing readable reports. EclEmma may be used on top of JUnit. EclEmma runs the JUnit test cases and generates the coverage report from the execution. EclEmma provides overall, package, and file level information on statement. EclEmma can be downloaded for a manual install from its SourceForge Project Page. Additionally, EclEmma can be installed via Eclipse Update Site. For more information on installing eclipse plugins, consult the tutorial on the subject. EclEmma's update site is |
|
Eclipse allows running Java programs directly from the workbench. Programs can be launched in different so called launch modes. In a standard Eclipse installation you can launch your programs either in Run or in Debug mode. EclEmma adds a new launch mode Coverage which is available from the Run menu and the toolbar:
Note: If the Coverage drop-down toolbar button is not visible in your current workbench perspective, open the Customize Perspective... dialog and enable the Coverage command group on the Commands tab. To gather the coverage report for a JUnit test suite, right-Click the test suite you want to run and go to
|
The coverage view should appear as soon as your test case has finished executing. The EclEmma coverage report shows coverage statistics for statement coverage (as calculated by number of executed instructions) as shown in Figure 5. To pull it up manually, go to
|
To export an HTML version of your coverage report, right click anywhere in the coverage report and go to
Browse and select a destination folder as shown in Figure 8.
|
For this exercise we will be using the CoffeeMaker project. Download the CoffeeMaker project from here or import the CoffeeMaker project that you used in the JUnit tutorial. For more information on CoffeeMaker, consult the CoffeeMaker User Stories and Black Box Test Cases. Unzip the CoffeeMaker project to your home directory and import the project into Eclipse. Please see the Rational XDE and Eclipse Import/Export Guide for instructions on how to import a project into Eclipse. We all know that most computer scientists love caffeine, so the Computer Science department is looking to put a coffee kiosk in the new building. The coffee kiosk must be able to make coffee for students to purchase. The CoffeeMaker code is complete; however, we need you to create and run unit tests until you have 90% coverage and a green bar on the CoffeeMaker, Inventory, and Recipe classes. Run your JUnit tests using EclEmma and generate a coverage report. (Hint: Run EclEmma on the initial project to see what coverage you already have, and what lines you need to test.) Deliverables to the TA
|