Laurie Williams, Dright Ho, Ben Smith and Sarah Heckman. [Contact Authors] |
| 1.0 | Introduction to djUnit |
| 2.0 | Running djUnit |
| 3.0 | djUnit Coverage Report |
| 4.0 | Exercise |
| 5.0 | Resources |
djUnit is an Eclipse plug-in that generates test coverage reports, tests with mock objects, and provide simple trace information about test cases. We will be using djUnit primarily as a coverage reporting tool. djUnit can be downloaded here. For more installation instructions, see the Installing Eclipse Plugins tutorial. Coverage (from the Yellow Book) is defined as "a measure of completeness of the set of test cases" meaning that the more source code that is executed by your test cases the better. 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 djUnit, help by automating the coverage process and providing readable reports. djUnit may be used instead of JUnit. djUnit runs the JUnit test cases and generates the coverage report from the execution. djUnit provides overall, package, and file level information on statement and branch coverage. |
2.1 There are two ways to run JUnit Test Cases or Test Suites.
|
The djUnit coverage report is broken into three areas and only reports coverage statistics for statement (line) and branch coverage. The first provides the overall coverage figures for the entire project. The second area provide coverage information about each package in the project. The last area provides coverage information about each file in the project. If you select the file name in the coverage report, the source code shown in the editor with indicators by the lines that are not covered by test cases.
|
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. 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. CoffeeMaker User Stories and Black Box Test Cases. 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 djUnit and generate a coverage report. (Hint: Run djUnit on the initial project to see what coverage you already have, and what lines you need to test.) Deliverables to the TA
|