Determine discretionary employee retirement

This preview shows page 13 - 21 out of 25 pages.

// determine discretionary employee retirement contribution if ( m_employee[ id ].WantsRetirement && EligibleForRetirement( m_employee[ id ] ) ) { companyRetirement = GetRetirement( m_employee[ id ] ); } grossPay = ComputeGrossPay( m_employee[ id ] ); // determine IRA contribution personalRetirement = 0; if (EligibleForPersonalRetirement( m_employee[ id ] ) { personalRetirement = PersonalRetirementContribution( m_employee[ id ], companyRetirement, grossPay ); } // make weekly paycheck withholding = ComputeWithholding( m_employee[ id ] ); netPay = grossPay - withholding - companyRetirement - governmentRetirement - personalRetirement; PayEmployee( m_employee[ id ], netPay ); // add this employee's paycheck to total for accounting totalWithholdings += withholding; totalGovernmentRetirement += governmentRetirement; totalRetirement += companyRetirement; } SavePayRecords( totalWithholdings, totalGovernmentRetirement, totalRetirement ); What test cases do we need to achieve Line coverage? Branch coverage? Complete condition testing? Partial condition testing?
Image of page 13

Subscribe to view the full document.

Loop Testing Design test cases based on looping structure of the routine Testing loops Skip loop entirely One pass Two passes N-1, N, and N+1 passes [N is the maximum number of passes] M passes, where 2 < M < N-1
Image of page 14
Loop Testing int ReadLine(istream & is, char buf[], int bufLen) { int count = 0; while (count < bufLen) { int c = is.get(); if (c != -1 && c != '\n') buf[count++] = (char)c; else break; } return count; } What test cases do we need? 1) Skip loop entirely: a. bufLen == 0 2) Exactly one pass: a. line of length 1 (including the '\n') OR bufLen == 1 3) Exactly two passes: a. line of length 2 OR bufLen == 2 4) N-1, N, and N+1 passes: a. lines of length bufLen-1, bufLen, and bufLen+1 5) M passes, where 2 < M < N-1 a. line of length bufLen / 2
Image of page 15

Subscribe to view the full document.