Self-Check Quiz Answers
Lectures 1 and 2
1. The purpose is to detect unexpected problems caused by program changes.
2. Alpha testing is conducted within the development environment; Beta testing is conducted within a user’s environment.
3. Black-box testing involves designing test cases based solely on the analysis of program requirements. White-box testing involves designing test cases based on the analysis of a program’s internal logic.
4. "a"
5. The general practice of recording and comparing indices of performance, quality, cost, etc., to help identify “best practices.”
Lectures 3 and 4
1. In the absence of requirements for a program, its correctness cannot be determined.
2. They are unclear and/or open to multiple interpretations.
3. The word “should” can be interpreted in different ways OR it is not clear if 0 and 10 are included in the range or not.
4. The assumptions underlying partition testing that have to hold in order for it to be equivalent in effect to exhaustive testing – i.e., that every element of a given equivalence class is “handled” either correctly or incorrectly by the program – is tenuous, at best. But then again, you might get lucky.
5. Because program errors can mask the detection/handling of other program errors.
Lectures 5 and 6
1. a. 3 (for Causes 1 and 3) X 2 (for Cause 2) X 2 (for Cause 4) = 12
b. 1 -- Cause values: F, T, T, T force both Effects to be True.
c. 3 (for Effect 8) + 1 (for Effect 9) = 4)
2. Identify values at the endpoints of the range and just beyond.
3. Design tests for reasonable but incorrect assumptions that may have been made by developers. Design tests to detect errors in handling special situations or cases. Design tests to explore unexpected or unusual program use or environmental scenarios.
Lectures 7 and 8
1. C-Use pairs for A: (1,2), (1,4), (1,5), (2,4), (2,5)
P-Use pairs for B: (1,<1,2>), (1,<1,3>)
2. 2 -- they are: <1,2,3,4> and <1,3,4>
3. statement, all-defs
4. statement, branch, condition, all-defs
5. 3 -- the number of enclosed regions in the program graph + 1
6. 4
Lectures 9 and 10
1. a. A1 = A0 + 1 A4 = A0 + 1
B1 = B0 B4 = B0 + 1
b. B0 A0 + 1 and B0 <= -A0 + 1 and B0 + 1 <= 0
2. “Killing a mutant” in Mutation Analysis means that the test set under evaluation has detected the change (the “mutation” introduced into the program. The higher the percentage of “mutants killed,” the better (the “more sufficient”) the test set.
3. 15(100/50-1) = 15
Lectures 11 and 12
1. One driver (at most) is required. Modules can be added one at a time with each step if desired. Supports both ‘‘breadth first’’ and ‘‘depth first’’ approaches.
2. No stubs are required. Easier to formulate input data for some subtrees. Easier to interpret output data for others. Subtrees may be integrated and tested in parallel.
3. An operational profile describes how a system is expected to be used in a particular end-user environment.
4. If modifications are removed, there may be differences in behavior between what is tested and what is used. Leaving modifications in the code avoid such discrepancies, but incur some overhead.
Lectures 13 and 14
1. Publish an agenda and stick to it. Handle emergency issues in a way that will not hurt people who don’t attend the meeting.
2. That of process “owner” and champion for an organization.
3. True, True, True
4. Because the process will be more effective if there is a single, well defined purpose.
Lectures 16 and 17
1. By instantiating a value for x, as in 2>5, and by quantifying the predicate, as in "x • x>5 (“every number x is greater than 5”).
2. pre-condition: {N≥1}
post-condition: {[(FOUND Л $ 1≤i≤N • A[i]=Y) V
(ØFOUND Л " 1≤i≤N • A[i]≠Y)] Л
A=A’ Л Y=Y’ } )
3. true, true, true
4. Two conditions must hold:
(1) {Y=X Л X<0} Y:=-X {Y=|X|} and
(2) {Y=X Л X≥0} A:=5 {Y=|X|}
both of which clearly do.
Lectures 18 and 19
1. Initialization: Does (y≥0 Л z=0 Л n=y) Þ z = x*(y-n)? Clearly.
Preservation: {n≠0 Л z = x*(y-n)}
z := z+x
{n≠0 Л z = x*(y-n) + x}
n := n-1
{n+1≠0 Л z = x*(y-(n+1)) + x} => I
Finalizaion: Does z = x*(y-n) Л n=0 Þ z = x*y? Clearly.
2. Measure: n
(1) n decreases with each iteration of the loop since n := n-1 is
executed with each iteration and n does not otherwise change.
(2) n is bounded from below by 0 since P Þ n≥0 initially and the loop
must terminate when n=0.
(3) n can assume only a finite number of values, (n, n-1, …, 0) before
reaching its lower bound since it is decremented by an integral
amount (1) with each iteration of the loop. )
3. a. w(2y-4)=z+2y º 2y(w-1)=z+4
b. (x is even Л x=8) V (x is odd Л x=9) º x=8 V x=9
4. (1) sp(if A>B then Z:=A, Z=B) = sp(Z:=A, A>B Л Z=B) V (A≤B Л Z=B)
= (Z=A Л A>B Л Z’=B) V (A≤B Л Z=B)
(2) (Z=A Л A>B Л Z’=B) V (A≤B Л Z=B) => (Z=A Л A>B) V (A≤B Л Z=B)
<=> Z=Max(A,B) √
Lectures 20 and 21
1. H0 º x=0 Л x=0 Л y=y0+x0
º x=0 Л y=y0+x0
H1 º x>0 Л x-1=0 Л y+1=y0+x0
º x=1 Л y=y0+x0-1
H2 º x=2 Л y=y0+x0-2
Hk º x=k Л y=y0+x0-k
closed form: x³0 Л y=y0+x0-x
2. We need to show: sp(T, i=1 Л t=1 Л x=1) => t=x5 where T is:
while i>3 do
t := t*x
i := i+1
end_while
K0 ≡ P
= i=1 Л t=1 Л x=1
K1 ≡ sp(S, b Л K0)
= t=t’x Л i=i’+1 Л i’≠3 Л t’=1 Л i’=1 Л x=1
= i=2 Л t=1 Л x=1
K2 ≡ sp(S, b Л K1)
= t=t’x Л i=i’+1 Л i’≠3 Л t’=1 Л i’=2 Л x=1
= i=3 Л t=1 Л x=1
K3 ≡ sp(S, b Л K2)
= t=t’x Л i=i’+1 Л i’≠3 Л t’=1 Л i’=3 Л x=1
= false
K4 ≡ sp(S, b Л K3)
= false
:
Kn ≡ sp(S, b Л Kn-1)
= false
Thus, sp(T, i=1 Л t=1 Л x=1) =
i=3 Л [(i=1 Л t=1 Л x=1) V (i=2 Л t=1 Л x=1) V (i=3 Л t=1 Л x=1) V
false V false V ...]
= i=3 Л t=1 Л x=1 => Q (t=x5) when S terminates (i.e., when i0≤3)
3. N, S, C, C
Lectures 22 and 23
1. Let G be x := x-2 and H be y := y-x. Then, by observation, g = (x,y := x-2,y) and h = (x,y := x,y-x). Therefore, by the Axiom of Replacement, it is sufficient to show: f = (x,y := x-2,y-x+2) = [g; h].
Does f equal h composed with g?
h o g = (x,y := x,y-x) o (x,y := x-2,y)
= (x,y := x-2,y-(x-2))
= (x,y := x-2, y-x+2)
= f
Yes. Therefore, f = [P]. )
2. Let G be x := x-3 and H be y := x=3. Then, by observation, g = (x,y := x-3,y) and h = (x,y := x,x+3). Therefore, by the Axiom of Replacement, it is sufficient to show: f = [if x>0 then g else h].
When p is true does f equal g?
(x>0) Þ (f = (x,y := x+3,y))
(x>0) Þ (g =(x,y := x+3,y))
Yes.
When p is false does f equal h?
(x£0) Þ (f = (x,y := x,x+3))
(x£0) Þ (g =(x,y := x,x+3))
Yes. f = [P].
3. term(f,P)? Yes. When x=0, the loop is not entered. When x>0, the Method of Well Founded Sets can be used to prove termination with measure "x".
Does (x=0) Þ ( f = I )? Yes, by definition of f.
Does (x¹0) Þ ( f = f o g )?
case a: Does (x<0) Þ ( f = f o g )?
(x<0) Þ ( f = undefined )
(x<0) Þ ( f o g = f o (x,y := x-1,y+2)
= undefined o (x,y := x-1,y+2)
= undefined )
case b: Does (x>0) Þ ( f = f o g )?
(x>0) Þ ( f = x,y := 0,y+2x )
(x>0) Þ ( f o g = f o (x,y := x-1,y+2)
There are two sub-cases to consider: (1) x=1, in which case x=0 after g, and (2) x>1, in which case x>0 after g.
sub-case (1): x=1
(x>0) Þ ( f o g = f o (x,y := x-1,y+2)
= (x,y := 0,y+2x) o (x,y := x-1,y+2)
= (x,y := 0,(y+2)+2(x-1))
= (x,y := 0, y+2x)
= f
sub-case (2): x>1
(x=1) Þ ( f o g = f o (x,y := x-1,y+2)
= I o (x,y := x-1,y+2)
= (x,y := 1-1, y+2(1))
= (x,y := 0, y+2x) )
Yes. Therefore, f = [P].
Lectures 24 and 25
1. f = (t³k -> t,y,x,k := k,y+t-k,x,k)
X f(X) foh(X0)
------
t k k0
y y+t-k x0-k0
x x x0
k k k0
Setting f(X)=foh(X0) gives:
k = k0
y+t-k = x0-k0
x = x0
k = k0
I: y+t-k = x0-k0
= x-k
y = x-k+k-t
= x-t
2. Extending MTTF (i.e., increasing reliability). This is so because statistical usage testing tends to find errors in failure-rate order, while coverage testing is not biased to find errors in any particular rate order.