Link Search Menu Expand Document

Homework 4 - Testing

Due 10/15/21 at 11am

Instructions

Submit these in slide format (ppt, pptx, or pdf) with each section on a different slide. Please do not put your name on the PDF, so that we can anonymize grading in Canvas. Number the questions/question parts. Questions in blue are optional/questions for you to think about to yourself.

You are graded on good-faith effort, not correctness. This means that you should attempt to answer every question, and if you did not reach an answer, you should describe your process and where you got stuck.

Testing definitions

Read Koopman 2010, Testing and Test Plans (Canvas login required. If this link doesn’t work, you can find this file on the Canvas site under “Files.”).

  1. If you have any questions about the reading, post them on Ed

  2. (8 pts) Given each of these possible defects, which testing method (from 23.2.1) would be most likely to catch each of them?

    1. Fix for one part of the code violates assumptions made in another part of code
    2. Mismatch between requirement and implementation in sensing module
    3. Input to user interace causes malfunction of system
    4. Communication between two components hangs

Coverage

The chapter reading explained that there are multiple ways to measure coverage. In white-box testing, we often talk about coverage of the structural logic of the code with a set of test cases. When we talk about “decision” (otherwise known as “branch”) coverage, we ask if, for every branching statement in the code (such as an if), there is at least one test case that exercises the “true” outcome of a branch, and at least one test case that exercises the “false” outcome of that branch. Similarly, when we talk about “condition” coverage, we ask the same question, but for conditions, or boolean sub-expressions, within a decision (for example, if(a < 0 || b == 3) contains two conditions, a < 0 and b == 3). A resource for explaining different kinds of structural testing, with examples, can be found here.

Consider the following code block. Determine a set of test cases sufficient to achieve:

  1. (6 pts) Full branch coverage

  2. (8 pts) Full condition coverage

if (x == 3 && y < 0 ) {
 // do something;
} else {
  // do something else
}

q = x + z;

if (q < y) {
  if (x == z) {
    // do another thing
  }
}

You may assume that the “do something” (and similar) lines do not modify x, y, and z.

You should provide a table where the columns are the branches (for question 1) or conditions (for question 2), and each row is a test tuple (x,y,z), with x, y, and z replaced by specific test values (such as (3, -1, 0)). A cell in the table should say “true” if the test values cause the specific branch or condition to evaluate to true, “false” otherwise, and “n/a” if the branch or condition is unreachable with the given values. For example,

testbranch x == 3 && y < 0branch q < ybranch x == z
(3,-1,0)truefalsen/a