Multiple-Choice Questions
Multiple-Choice Questions
Multiple-Choice Questions
a. True
b. False
a. True
b. False
a. No I/O
b. Fast
c. Non-deterministic
c. Typically results in an intractably large set of test cases even for small programs
a. Unit tests should not perform I/O, whereas integration tests may do so
b. Unit tests should be deterministic, whereas integration tests may have non-determinism
c. Unit tests should be fast (less than half a second), whereas integration tests may be slower
d. Unit tests must be black-box tests, whereas integration tests must be white-box tests
6. Which of the following is not a difference between black-box and white-box testing?
a. Black-box tests are based only on the interface of a component, whereas white-box tests are
based on the implementation
b. Black-box tests often focus on boundary cases, whereas white-box tests tend not to
c. White-box tests often aim to achieve particular levels of code-coverage, whereas black-box
tests do not
d. In test-driven development, the developers generally write black-box tests, and not white-box
tests
7. In __________, you hook everything together and treat the system like a black box.
a. test-driven development
b. system testing
c. unit testing
d. integration testing
1. b
2. a
3. c
4. d
5. d
6. e
7. b
Problem: Draw a control flow diagram for this function. Label each edge with an uppercase letter.
Input
Covers
x y
Solution:
Problem: Draw a control flow diagram for this function. Label each node in the graph with a capital let-
ter, and label each edge with a lowercase letter.
1. Fill in the table below with a test suite that provides statement coverage of the “blammo” code. In the
covers column, list the relevant labeled items in your CFG that each test case covers. Some cells in
the table may be left blank.
Input
Covers
u v
2. Fill in the table below with a test suite that provides path coverage of the “blammo” code. Cover no
more than 1 iteration of the loop. In the covers column, list the relevant labeled items in your CFG
that each test case covers. Some cells in the table may be left blank.
Input
Covers
u v
Solutions:
1.
2.
Problem: Draw a control-flow graph for the following function. Label each edge in the graph with an
uppercase letter.
Solution:
Problem: Fill in the table below with a test suite that provides path coverage of the min_of_three
function from the previous question. In the covers column, list the relevant labeled edges in your CFG
that each test case covers. Some cells in the table may be left blank.
Input Expected
Covers
x y z Output
Solution:
Consider the following control-flow graph for a gcd function in answering the questions below.
H
Problem: Fill in the table below with a test suite that provides condition coverage of the gcd function
(see control-flow graph above). In the Covers column, list the relevant labeled edges in the CFG that each
test case covers. Some cells in the table may be left blank.
Input Expected
Covers
x y Output
Problem: Fill in the table below with a test suite that provides path coverage of the gcd function (see
control-flow graph above). In the Covers column, list the relevant labeled edges in the CFG that each test
case covers. Some cells in the table may be left blank. You need only cover executions that involve 1 iter-
ation of the loop.
Input Expected
Covers
x y Output
Solution: Condition Coverage