COMP 2100 Lab Exercise 4: Testing...Testing...
(15 points)
Turn in before you leave today.

Do this exercise with a designated partner. You are to complete it during today’s lab period.

Perform black box testing of the following method:

/**
 *  Determine which forms a person is required to submit based on various properties.
 *
 *  @param age  Applicant's age in years.  Assume non-negative value.
 *  @param hasDisability  Applicant's disability status.  True or false.
 *  @param earnings  Applicants annual earnings in dollars.  Assume non-negative value.
 *  @return ArrayList of form names
 */
public ArrayList requiredForms( int age, boolean hasDisability, double earnings);

This method will return a collection of required forms based on these criteria:

Applicants under the age of 18 should use form A, while those 18 or above should use form B. However, disabled people of any age should use form C instead. Senior citizens (age 65 or older) should complete form D in addition to any other forms. Anyone who is not disabled and not a senior citizen, and who earns $50,000 or more per year, should complete form E in addition to any other forms.

Based on that description and the method specification, design and perform black box tests as instructed:

  1. Start by downloading the ZIP file ex4.zip and extracting into your workspace. It includes Java files you will need to conduct tests. Only one of you needs to do this.
  2. I will hand out an Answer Sheet. Add your names to it.
  3. What are the equivalence classes for the three parameters? An equivalence class for a parameter is a range of parameter values that all yield the same result (assuming other parameters' values are fixed). The equivalence class can consist of a single value, such as for Boolean parameters, or a range of values. You need not consider negative age or earnings values. Fill in the Part A table provided on the Answer Sheet with the ranges. Not all cells are needed.
  4. Fill in the table of test cases based on the equivalence classes. You will test boundary cases only, and only for boundaries that divide two equivalence classes. For example: you do not need to test age == 0, because you can assume age is non-negative so there is not an equivalence class for ages less than 0. See provided Part B table on the Answer Sheet. Each row represents one test case. I've filled one in to give you an example. Complete all columns through Expected Result. You will not need all the rows, but you are expected to define and run all boundary test cases.
  5. Run the test cases! Open FormsTest.java, compile and run it. You'll see it displays the results of the provided test case. Study the code for the provided test case to see the necessary format for calling testAndPrint() to perform the test and output its results. Be sure to read the testAndPrint() comments to determine parameter formatting, especially expected results. Then enter your additional test cases into main() at the indicated location (just after the provided test case). Add all test cases into the program at the same time so you end up with a long list of them. Don't delete any test cases! Double-check to make sure you've specified the test cases correctly, then compile and run FormsTest. Record the Actual Results and Pass/Fail status for each test case in the Part B table.
  6. Is the requiredForms() method correctly written? If not, can you determine what the defect is (this is optional)? Do you think your test cases are correctly written and sufficient? Write a short report of your findings in the blank space provided on the back of the Answer Sheet.

Scoring

PointsDescription
3 3: Identifying equivalence classes (Answer Sheet Part B)
6 4: Specifying test cases (Answer Sheet Part C)
3 5: Running test cases (Answer Sheet Part C)
3 6: Analysis of test results (Answer Sheet Part D)

To Turn In

Give me your completed Answer sheet before you leave today.
[ COMP 2100 | Peter Sanderson | Math Sciences home page | Otterbein ]

Last updated: