Question: ASSIGNMENT 2 Purpose This assignment is aimed at helping you understand how the white box testing method known as control flow testing works. You should
ASSIGNMENT
Purpose
This assignment is aimed at helping you understand how the white box testing method known as control flow testing works. You should have read section of the text book before attempting this assignment. For a more comprehensive explanation of control flow testing, please refer to the attached document.
You are required to complete the tasks described below.
Test software
The following program has been implemented for a newly proposed tax calculation formula for residents of a fictitious country.
incomeList: the array recording the individual income items
childList: the array recording the ages of children supported by this person
parentList: the array recording the ages of parents supported by this person
public double computeTaxdouble incomeList, int parentList, int childList
double taxAmount ;
double incomeAmount ;
calculate the income amount
for int i ; i incomeList.length; i
incomeAmount incomeAmount incomeListi;
calculate the basic tax
if incomeAmount
taxAmount incomeAmount ;
else if incomeAmount && incomeAmount
taxAmount incomeAmount ;
else if incomeAmount && incomeAmount
taxAmount incomeAmount ;
else if incomeAmount
taxAmount incomeAmount ;
calculate the tax exemption from having children
int taxExemption ;
int numOfChild childList.length;
while numOfChild
if childListnumOfChild
taxAmount taxAmount ;
taxExemption taxExemption ;
numOfChild;
calculate the tax exemption from having parents
for int j ; j parentList.length; j
if parentListj
taxAmount taxAmount ;
taxExemption taxExemption ;
the maximum tax exemption is each person
if taxExemption
if taxAmount
return taxAmount;
else ie taxAmount
return ;
else ie taxExemption
taxAmount taxAmount taxExemption ;
return taxAmount;
Your Tasks
Design test cases to achieve the statement coverage on the function computeTaxlist the statements covered by each test case using the line number of each statement If it is not feasible, explain the reason. Use the minimum number of test cases to achieve the statement coverage.
For this portion, create a control flow chart diagram; identify each path with a letter, similar to figure in the textbook. Design test cases to achieve path coverage on the function computeTax Identify paths covered by each test case using your notation in the diagram. If path coverage is not feasible, explain the reason. Use the minimum number of test cases to achieve the path coverage.
Design test cases to achieve loop coverage see below on the function computeTaxlist the loops covered by each test case If it is not feasible, explain the reason. Try your best to use the minimum number of test cases to achieve the loop coverage. Consider a loop covered if at least in one test the loop body was executed times, in a second test the body was executed exactly once, and in another test the body was executed more than once.
Special Instructions
For each level of coverage, provide a brief explanation of your work. This should include any assumptions you have made.
Test cases should be presented in a table with each row showing the following:
Test ID # input data, statementspathsloops covered by the test case, expected output, actual output, passfail and coverage. You may add additional columns to display key variables such as tax exemption.
See Understanding Software Test Cases for tips on how test cases should be written
Code coverage should be shown by listing the statements using line numbers for each test case.
Your path diagram may be created with a drawing tool or NEATLY handwritten and inserted into your work.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
