# SE-2832 Introduction to Software Verification

Dr. Mark Sebern -- Spring quarter 2013-2014

## Lab 2

Revised: 19 March 2014

### Acknowledgment

This lab was developed by Dr. Walt Schilling; all errors in its adaptation are the responsibility of the instructor.

### Overview

In this lab, you will use EclEmma to collect code coverage metrics that may provide some insight into the effectiveness of tests written for a target application.

### Tool installation

Install the EclEmma Eclipse plugin:

1. From the Eclipse Help menu, select Install New Software....
3. Enter "EclEmma" in the Name field and "http://update.eclemma.org/" in the Location field, and click OK.
4. Select "EclEmma" in the list of available software and click Next >.
5. Complete the rest of the usual Eclipse plugin installation steps, including accepting the license.

### Normal unit test execution

Now, unZIP the first (non-alternate) version of the project code and make an Eclipse project incorporating it, adding the JUnit4 library to the build path. Then run the JUnit tests in TaxCalculatorTest.java, to make sure they are set up correctly.

### Initial coverage testing

In Eclipse, open the following files so they are displayed in the source code tabs:

• TaxCalculator.java
• TaxCalculatorInterface.java
• TaxCalculatorTest.java

In the Eclipse Package Explorer, right-click on the JUnit test tile (TaxCalculatorTest.java) and select Coverage As->JUnit Test. The coverage summary should appear in the Coverage window (located in the console area). You can expand the items in the Element column to see which methods have been tested and their level of coverage. You can also double-click on a filename in the Coverage window, to bring it up in a source code window, where lines should be marked with the following colors to show execution coverage:

• Green: executed
• Yellow: partially executed
• Red: not executed

To export a copy of the coverage report in HTML:

• Right-click in the Coverage window
• Select Export Session...
• Select Java->Coverage Report
• Select an available coverage session
• Provide a destination where the HTML report should be store

### Alternate coverage testing

Next, repeat the coverage testing process with a second project incorporating the "alternate version" files. This ZIP file contains only the program source code, so you'll have to copy over the tests from the first project.

Re-run the coverage analysis for the tests and compare the results with the original version.

### Test case improvement

Based on the coverage results, write new test cases to improve the code coverage. See whether you can reach 100% coverage for both implementations, and reflect on the reasons why you were successful (or not) in doing so.

### Assignment submission (due by 11:59PM CDT, Monday, March 24)

• Your name and assignment identification ("SE-2832 Lab 2")
• The reports generated by the EclEmma coverage tool; you may be able to paste the HTML reports into Word, but make sure they are readable.
• A description of changes you made to the JUnit tests in an attempt to improve coverage, and the results of those efforts.
• Your observations on the lab experience and any remaining questions that you have.

Put this report in the top-level directory of your first ("non-alternate") project.

### Appendix: Tax Law

This information courtesy of Dr. Schilling.

Taxes are complex, but for this assignment, they have been simplified.

#### Filing Status and Obligation to File

The first thing of importance is the person’s filing status and whether he or she is required to file a return at all. A return may indicate that a person is:

• single
• married filing jointly
• married filing separately
• a qualifying widow(er)

While you will not need to check the conditions that would quality a person to file using one of these categories, you will need to use the categories to test your program.

Depending on the filing status, a person is required to file an income tax return with the IRS if the criteria of Table 1 are met.

Table 1. 2008 Filing Requirements Chart for Most Taxpayers (From IRS Publication 501)

IF your filing status is... AND at the end of 2008 you were... THEN file a return if your gross income was at least...
Single Under 65 $8950 65 or older$10300
Head of household Under 65 $11500 65 or older$12850
Married, filing jointly Under 65 (both spouses) $17900 65 or older (one spouse)$18950
65 or older (both spouses) $20000 Married, filing separately Any age$3500
Qualifying widow(er) Under 65 $14400 65 or older$15450

The constructors for the Tax Calculator are responsible for accepting the name of the filer, the type of filer, and the filer’s age, along with the spouse’s age if the filing status is married (separate or joint filing).

#### Taxable Income

Income tax is based upon the taxable income of the filer. The taxable income is determined by taking the gross income and subtracting the standard deduction from this amount. The standard deduction amount depends on the filing status and the age of the filer. This information is provided in Table 2.

Table 2. Standard Deduction

Filing Status Base Standard Deduction
Single $5450 Married, filing separately$5450
Head of household $8000 Married, filing jointly$10900