You are on page 1of 149

The Art of

Software Testing
Second Edition

Glenford J. Myers
Revised and Updated by

Tom Badgett and Todd M.Thomas


with Corey Sandler

Copyright 2004 by Word Association, Inc. All rights reserved.


Published by John Wiley & Sons, Inc., Hoboken, New Jersey.
Published simultaneously in Canada.

,,,,,,,,
v.1.2 7/1/2008


1979 Glenford J.Myers
1 25

2 120
Corey Sandler Fix Your
Own PC 7 Tom Badgett PowerPoint
Office 4

20 80 90

2
Myers 1 Web

Glenford Myers

ii


1979 1
50 50
25

1979

2 3

iii

4 5 6
7
8 9
web

Glenford J . Myers
Tom Badgett
Todd M . Thomas
Corey Sandler

iv

1 .......................................................................................1
2 ..............................................................................4
2.1 .............................................................................................4
2.2 .............................................................................................7
2.3 ...............................................................................................11
2.4 ...................................................................................................................15
3 ....................................................................................16
3.1 (Inspections And Walkthroughs) ...................................................17
3.2 (Code Inspections).............................................................................18
3.3 ...............................................................................20
3.4 (Walkthroughs) ..................................................................................29
3.5 (Desk Checking) ................................................................................30
3.6 (Peer Ratings) ....................................................................................31
3.7 ...................................................................................................................32
4 ................................................................................................33
4.1 (White-Box Testing) ..........................................................................34
4 .2 (Error Guessing) ...............................................................................68
4.3 ...........................................................................................................70
5 ............................................................................................71
5.1 ...................................................................................................71
5.2 ...........................................................................................................80
5.3 .......................................................................84
5.4 ...........................................................................................................91
6 ................................................................................................93
6.1 (Function Testing)..............................................................................98
6.2 (System Testing) ................................................................................99
6.3 (Acceptance Testing) .......................................................................109
6.4 (Installation Testing)........................................................................109

6.5 .........................................................................................110
6.6 .................................................................................................112
6.7 .............................................................................................117
7 (DEBUGGING)........................................................................................118
7.1 (Debugging by Brute Force)........................................................119
7.2 (Debugging by Induction) ...........................................................120
7.3 (Debugging by Deduction) ..........................................................123
7.4 (Debugging by Backtracking) .....................................................126
7.5 (Debugging by Testing) ...............................................................126
7.6 .....................................................................................................127
8 ..........................................................................................................131
8.1 .................................................................................................131
8.2 .............................................................................................135
8.3 .............................................................................................137
8.4 .................................................................................................................141
............................................................................................................................142

1
25

20 70

GUI

l
1 1
23 2510

2
3 224

4
334343433
5 0
6
7 0
l23

8 7
123132312
9 0
124121530
10

124142412
11

0000

12

2.53.5

5.5
13

?
14

1 13

7.8 14

JavaC++

(vision)

2.1

15
l0

10

123 000

2.2

2.2.1
/

384238423842

-345 2A
2

C++
C++

C++

222
333 4

2.2.2

2-1

2-1 10~20
20 DO DO IF
a~ b
1014 100
520+519 51 5

10
300 320

2-1

2-1

10

Java
IF
if (a b < c)
System.Out.println(a-b<c);
c a-b
a b

2.3

2-l

21

10

11

1
2

12

125

13

9
2-2
A B
A B A
A B

14

2-2
10

2.4

15

20
70

()

16

3.1 (Inspections And Walkthroughs)

3070

3070
70 70
2

17

(
)

3.2 (Code Inspections)

1.

18

2.

(
)

90120
150

19

3.3

if-else do-while

3.3.1
1.

2.
3.

4.
dangling reference

20

5.
FORTRAN EQUIVALENCE
COBOL REDEFINES
FORTRAN A B
EQUIVALENCE A
B

6. CC++ COBOL

7.

8.
C++

9.

10.
(off-by-one)
11.

21

3.3.2
1.

DIMENSION C=A(I)

2.
Java

3.

4.
5. FORTRAN

DATA
6. VOLT VOLTS

3.3.3
1.
2.

Java
int
int
int
z =

x = 1;
y = 2;
z = 0;
x/y;

22

System.out.println("z = " + z);


OUTPUT:
z = 0
3.
4.
5.

6. 0
7.
100.l l.0
8.
PROBABILITY 1.0
9.

10. i
2*i/2 == i i

3.3.4
1.

2.

3.

4.

23

5.

i 210 2<i<10
(2<i)(i<10) i x y i>x ||y
(i>x)||(i>y)
if(a==b==c) x>y>z
(x>y)(y>z)
6.

7.
(if((a==2)(b==2)||(c==3))

8.
if((x==0 && (x/y)>z)
FALSE
0

3.3.5
1. GOTO

GOTO (200300400)i
i 12 3
2.

3.
4.

24

for {i==xi<=zi++} {
...
}
while(NOTFOUND){
...
}
NOTFOUND x z
5.
fall-through
D0 I=1 to TABLESIZE WHILE (NOTFOUND)
NOTFOUND
6. 0
0
Java 10 11

for(int i=0;i<=10;i++){
System.out.println(i);
}
10
for(int i=0;i<=9;i++) {
System.out.println(i);
}
7. do-while {...}
while do

8. 12
3 l 2 3

25

3.3.6
1. parameter
argument
2.
3.

4.
5.
6.
7.
8.
PL/1
A: PROCEDURE(W,X);
W=X+1;
RETURN
B: ENTRY(Y,Z);
Y=X+Z;
END;
9.
10.

11. FORTRAN

CALL SUBX(J, 3)
SUBX 3

26

3.3.7 /
1.
2.
3. I/O FORTRAN
FORMAT READ WRITE (
)
4.
5.
6.
7.
8. I/O
9.

3.3.8
1.

2.

3.

4.

27

5.
3-l 3-2
3-1

1.

1.

2.

2.

3.

3.

4.

4.

5.

5.

6.

6. 0

7.

7.

8.

8.

9.

9.

10.

10.

11.

1.

1.

2.

2.

3.

3.

4.

4.

5.

5.

6.

6.
7.
8.

3-2

1.

1.

2.

2.0PEN

3.

3.I/O

4.

4.

5.

5.

6.

6.

28

7.DO/END

7.

8.

8. I/O

9.

1.

1.

2.

2.

3.

3.

4.

4.

5.

5.

6.

7.

8.
9.
10.
11.

3.4 (Walkthroughs)

(1)(2)
(3)(4)
(5)(6)

29

3.5 (Desk Checking)

30

3.6 (Peer Ratings)

620
6
Java

4
30
4 4
17 7

31

3.7

32

4
2

33

4.1 (White-Box Testing)


4.1.1 (Logic-Coverage Testing)

4-1

4-1

34

4-l Java

Public void foo(int a, int b, int x) {


if (a>1 && b == 0) {
x=x/a;
}
if (a==2 || x>1) {
x=x+1;
}
}
ace
a A=2B=0X=3X

X>0
X abd

switchdo-while if-else FORTRAN


GOTO

ON ON-unit
ON

35

ON

/ select(case)
Java IF GOTO FORTRAN
GOTO GO-TO-DEFENDING-ON COBOL
/

4-1 ace abd acd abe

A=3B=0X=3 A=2B=1X=1

50% X
X>1 X<1

ON

DO K=0 to 50 WHILE (J+K<QUEST)


K 50 J+K QUEST?
K <= 50K >50 J+K<QUESTJ+K>=QUEST

4-1 A>1B=0A=2 X>1


a A=2A<2X>1 X<=1

36

1A=2B=0X=4

ace

2A=1B=1X=1

adb

DO K=0 to 50 WHILE (J+K<QUEST)

K = 0 K = 51 WHILE

J+K<QUEST

IF (A&B)A B
A B IF THEN 4-1

1A=2B=0X=3
2A=1B=1X=1

abe

37

4-2 4-2 4-l

H K

H
A>1

B=0

I
Y

N
X=X/A

J
A=2
Y
N
K

X>1

N
d

X=X+1

4-2 4-1
4-2

38

NOTFOUND=TRUE;
DO I=1 TO TABSIZE WHILE (NOTFOUND); /*SEARCH TABLE*/
searching logic;
END

1.

I<=TABSIZE NOTFOUND

2.

I<=TABSIZE NOTFOUND

3.

I>TABSIZE NOTFOUND

4.

I>TABSIZE NOTFOUND

/
4-l 8
1.

A>1B=0

2.

A>1B<>0

3.

A<=1B<>0

4.

A=2X>1

5.

A=2X<=1

6.

A<>2X>1

7.

A<>2X<=1

5 8 if X
if if
8 8
4

A=3B=0X=4
A=2B=1X=1
A=1B=0X=2
A=1B=1X=1

15
26
37
48
39

4-1 4 4
4 acd
8

if (x==y && length(z)==0 && FLAG) {


j=1
else
i=1;
}

1
2 ON

4.1.2 (Equivalence Partitioning)


2

1.

2.

40

l 0

1
2

4-3
1

4-3

41

1. 1 999)
1<<999 )
<1>999
2. )

3.

4.
,

1.
2.

3.

l999 )

42

XYZ 0
XYZ

4.1.3
FORTRAN
DIMENSION (
FORTRAN DIMENSION

DIMENSION
DIMENSION
DIMENSION ad[,ad]
ad
n(d[ ,d] )
n d 1~6
1 7

[lb: ]ub
lb ub -65534~65535
lb
1ub lb lb
DIMENSION

4-l
4-1
Input Condition
Number of array descriptors
Size of array name
Array name
Array name starts with letter

Valid
Equivalence
Classes
one (1), > one (2)
16 (4)
has letters (7), has digits
(8)
yes (10)

Invalid
Equivalence
Classes
none (3)
0 (5), > 6 (6)
has something else (9)
no (11)
43

Number of dimensions
Upper bound is
Integer variable name

17 (12)
constant
(15),
integer
variable (16)
has letter (19), digits (20)

Integer variable starts with yes (22)


letter
Constant
-6553465535 (24)
Lower bound specified
Upper bound to lower bound
Specified lower bound
Lower bound is
Multiple lines

0 (13), > 7 (14)


array
element
name
(17),something else (18)
has has something else
(21)
no (23)

65534 (25), >65535


(26)
yes (27),
no (28)
greater than (29), equal less than (31)
(30)
negative (32), zero (33), >
0 (34)
constant
(35),
integer array element name (37)
variable (36),
something else (38)
yes (39),
no (40)

DIMENSION A(2)
14710121524282940

DIMENSION A 12345 (1,9,J4XXXX,65535,1,KLM


X
100),BBB[-65534:100,0:1000,10:10,I:65535]

(3)DIMENSION
(5)DIMENSION (10)
(6)DIMENSION A234567(2)
(9)DIMENSION A.1(2)
(11)DIMENSION 1A(10)
(13)DIMENSION B
(14)DIMENSION B(4,4,4,4,4,4,4,4)
(17)DIMENSION B(4, A(2))
(18)DIMENSION B(4, 7)
(21)DIMENSION C(1, 10)
(23)DIMENSION C(10, 1J)
(25)DIMENSION C(-65535:1)
(26)DIMENSION C(65536)
(31)DIMENSION D(4:3)
(37)DIMENSION D(A(2):4)

44

(38)D(.:4)
18

4.1.4 (Boundary-Value Analysis)

1.

2.

1.

-1.0 +l.0-1.01.0-1.001 1.001

2.

l~255 0l255 256

45

3. 1FICA 1
$0.00$1165.25
$0.00 $1165.25
$1165.25
sin

4. 2
4
0 l 4 5
5.

6.
1
0

3-4-5 1-2-4
A+ B>=C A+ B>C
l-2-3

MTEST OCR
80

2 l 3
l999 10 59 l

46

50
10 59
51 100 101 150
3
1 9
10 59 l 50
50 10 59 51
100 101 150 200
4-4 :
1.

2.
3.
4.

47

80

150

34

9 10

59 60

51100

9 10

59 60

59 60

51100

9 10

59 60

79 80

79 80

79 80

150

9 10

150

9 10

79 80

59 60

79 80

4-4 MTEST

l999
50
15051999 0l5051 999

60

1.
2.

48

3. 1
4. 80
5. 1
6. 50
7. 51
8. 999
9. 0
10.
11.
12.
13.

14. 0
15. 1
16. 200
17. 201
18.
19.
20.
21.
22.
23.

0 14
1 15
200 16
24.

49

25.
26.
27. 0
28. 100
29.
30.
31.
32.

33.
34. 0 0
35. 0 100
36. 0
33 34
0 0
14

37.
38.
39.
40.
41.
42.
42

50

4.1.5 (Cause-Effect Graphing)

MTEST

1.

Web

2.

3.

51

4.

5.

6.
4-5 0 10
1 identity a 1
b 1 b 0not a 1 b 0 b 1or
a b c 1 d 1 d 0and a b
1 c 1 c 0or and

4-5

AB

X12 X13

52

1A
2B
3

70
71 X12
72 X13
4-6 11

4-7

4-6

4-7 4-6

53

4-6
1 2 1
AB)
4-8 E a
b 1(a b 1 I abc
1abc 0 O ab
1, R a 1b 1a 1 b 0

4-8
4-9 M a 0,
b 0

54

4-9
1 2
E
4-10

4-10

DISPLAY
4-11

hexloc1
16 09AF
0
hexloc2
16
hexloc1hexloc2
END(hexloc1)
bytecount
hexloc1

55

l6
bytecount hexloc1
1 bytecount 1

xxxxxx word1 word2 word3 word4


xxxxxx word1 hexloc1
4
4 4 16

M1
M2
M3 0

4-11 DISPLAY
:
DISPLAY
0 1
DISPLAY 77F
77F 3
DISPLAY 77F-407A
77F- 407A

56

DISPLAY 77F.6
77F
DISPLAY 50FF-END
50FF

1.
2. hexloc1
3. hexlocl 1-6
4. hexloc1
5 END
6 hexloc2
7 bytecount
8
9. hexloc2
10. hexloc2 l-6
11. hexloc2
12. hexloc2 hexloc1
13. bytecount
14. bytecount 1-6
15. bytecount + hexloc1 1
16. bytecount >= 1
17.
18
5 8
(1) END(2)hexloc2;
3bytecount(4)(5)
91. M1
92 M2

57

93. M3
94.
95.
96.
97.

4-12 32
35 36
36 1, 91()

58

4-12 DISPLAY
4-13

59

4 -13
4-13

l 2 3 4 2 3
4-14 5
678 require
4-8 R--
17 8
8 17

60

4-14 DISPLAY

1.

2.

3.

4.

2
1.

1 or or
1path sensitizing

61

2.

0 and 0
0
1 1

3.

0 and 0
and

4-15 4-16

x l
a = bl l
x 0
a =b =0

x l
a = b=c=l
x 0 a=b=c=0
3abc001010100011
1011102

4-15
0 3
5 6 0 2
5 1 6 0 5 l
5 l 5 0 6 l
6 1 1
5 l 1 2 1
1 4 5 1
4 0 13

62

0
1
1
1
0

0
0
0
0
0

0
0
0
1
1

0
0
1
0
1

5=06=0
5=l6=0
5=16=0
5=16=0
5=06=1

4-16

4-14 91
36 0 91 32 35 000l l0 36
0 2 3
91

91 4-17 1 11 l
3 13 32 0 35 l
4 10 32 1 35 0 3
32 35 0 21 11

63

l 6
57 8 0

4-17
12 15 92 16 17 93
4-18

64

4-18
38 38

7FFF
1
2
3
4
5
6
7
8
9
10
11
12

DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY

234AF74-123
2ZX4-3000
HHHHHHHH-2000
200 200
0-22222222
1-2X
2-ABCDEFGHI
3.1111111
44.$42
100.$$$$$$$
10000000-M
FF-8000

(91)
(91)
(91)
(91)
(91)
(91)
(91)
(91)
(91)
(91)
(91)
(92)
65

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY
DISPLAY

FFF.7001
8000-END
8000-8001
AA-A9
7000.0
7FF9-END
1
21-29
4021.A
END
F
.E
7FF8-END
6000
A0-A4
20.8
7001-END
5-15
4FF.100
END
20
11
7000-END
4-14
500.11

(92)
92)
(92)
(93)
(93)
(94, 97)
(94, 97)
(94, 97)
(94, 97)
(94, 96)
(94, 96)
(94, 96)
(94, 96)
(94, 96)
(94, 96)
(94, 96)
(94, 96)
(95, 97)
(95, 97)
(95, 97)
(95, 96)
(95, 96)
(95, 96)
(95, 96)
(95, 96)
(95, 96)

22 33
95 94 37

66

DISPLAY
4 18
26 16

hexloc2 hexloc1

hexloc2 = hexloc1
hexloc2 > hexloc1

DISPLAY

1.

hexloc1 1

2.

hexloc1

3.

hexloc1

4.

hexloc1 = 0

5.

hexloc1 = 7FFF

6.

hexloc1 = 8000

7.

hexloc2

8.

hexloc2

9.

hexloc2

10. hexloc2 = 0
11. hexloc2 = 7FFF
12. hexloc2 = 8000

67

13. hexloc2 = hexloc1


14. hexloc2 = hexloc1 + 1
15. hexloc2 = hexloc1 1
16. bytecount
17. bytecount
18. bytecount
19. bytecount = 1
20. hexloc1 + bytecount = 8000
21. hexloc1 + bytecount = 8001
22. 16 ()
23. 17 ()
60 ( 37+23 )

37
23

1
1 91 92 97

4 .2 (Error Guessing)

68

0
0 0

l
2 2 16
3 2 1 2 l 15
17
MTEST

2 3

23

69

DISPLAY

DISPLAY 100-

DISPLAY 100.

DISPLAY 100-10A 42

DISPLAY 000-0000FF

4.3

1.

2.

3.

4.

5.

70

500

1.

2.

3.

5.1

71

4
BONUS
$2,000
$150,000$1000 2
5-1
0 l
2

5-1 BONUS
5-2 ESIZE DSIZE
PL/l
PL/1
PL/l

5-2 $200,$100

72

BONUS : PROCEDURE(EMPTAB,DEPTTAB,ESIZE,DSIZE,ERRCODE);
DECLARE 1 EMPTAB (*),
2 NAME CHAR(6),
2 CODE CHAR(1),
2 DEPT CHAR(3),
2 SALARY FIXED DECIMAL(7,2);
DECLARE 1 DEPTTAB (*),
2 DEPT CHAR(3),
2 SALES FIXED DECIMAL(8,2);
DECLARE (ESIZE,DSIZE) FIXED BINARY;
DECLARE ERRCODE FIXED DECIMAL(1);
DECLARE MAXSALES FIXED DECIMAL(8,2) INIT(0); /*MAX. SALES IN
DEPTTAB*/
DECLARE (I,J,K) FIXED BINARY; /*COUNTERS*/
DECLARE FOUND BIT(1); /*TRUE IF ELIGIBLE DEPT. HAS EMPLOYEES*/
DECLARE SINC FIXED DECIMAL(7,2) INIT(200.00); /*STANDARD INCREMENT*/
DECLARE LINC FIXED DECIMAL(7,2) INIT(100.00); /*LOWER INCREMENT*/
DECLARE LSALARY FIXED DECIMAL(7,2) INIT(15000.00); /*SALARY
BOUNDARY*/
DECLARE MGR CHAR(1) INIT('M');
1 ERRCODE=0;
2 IF(ESIZE<=0)|(DSIZE<=0)
3
THEN ERRCODE=1; /*EMPTAB OR DEPTTAB ARE EMPTY*/
4
ELSE DO;
5
DO I = 1 TO DSIZE; /*FIND MAXSALES AND MAXDEPTS*/
6
IF(SALES(I)>=MAXSALES) THEN MAXSALES=SALES(I);
7
END;
8
DO J = 1 TO DSIZE;
9
IF(SALES(J)=MAXSALES) /*ELIGIBLE DEPARTMENT*/
10
THEN DO;
11
FOUND='0'B;
12
DO K = 1 TO ESIZE;
13
IF(EMPTAB.DEPT(K)=DEPTTAB.DEPT(J))
14
THEN DO;
15
FOUND='1'B;
16
IF(SALARY(K)>=LSALARY)|CODE(K)=MGR)
17
THEN SALARY(K)=SALARY(K)+LINC;
18
ELSE SALARY(K)=SALARY(K)+SINC;
19
END;
20
END;
21
IF(-FOUND) THEN ERRCODE=2;
22
END;
23
END;
24
END;
25 END;

5-2 BONUS

IF DO
DO
DO

73

DO DO

2
6
9
13
16
21

IF (ESIZE<=O) | (DSIZE<=0)
IF (SALES(I) >= MAXSALES)
IF (SALES(J) = MAXSALES)
IF (EMPTAB.DEPT(K) = DEPTTAB.DEPT(J))
IF (SALARY(K) >= LSALARY) | (CODE(K) =MGR)
IF(-FOUND) THEN ERRCODE=2

6
5-1
10
5-l
16

5-1
Decision True Outcome
2
ESIZE or DSIZE 0.
6
Will always occur at least once.
9

Will always occur at least once

13

There is an employee in an eligible


department.
An eligible employee is either a
manager or earns LSALARY or
more.
All eligible departments contain no
employees.

16
21

False Outcome
ESIZE and DSIZE > 0.
Order DEPTTAB so that a
department with lower sales occurs
after a department with higher sales.
All departments do not have the same
sales.
There is an employee who is not in an
eligible department.
An eligible employee is not a
manager and earns less than
LSALARY.
An eligible department contains at
least one employee.

5-l 10 5-3
2

74

1
2

ESIZE = 0
All other inputs are irrelevant
ESIZE = DSIZE = 3
EMPTAB
JONES E D42 21,000.00
SMITH E D32 14,000.00
LORIN E D42 10,000.00

DEPTTAB
D42
D32
D95

10,000.00
8,000.00
10,000.00

ERRCODE = 1
ESIZE, DSIZE, EMPTAB, and
DEPTTAB are unchanged
ERRCODE = 2
ESIZE, DSIZE, and DEPTTAB are
unchanged
EMPTAB
JONES E
D42 21,100.00
SMITH E
D32 14,000.00
LORIN E
D42 10,200.00

5-3

0DSIZE<=0

5-2
14 5-4

ESIZE = DSIZE = 0
All other inputs are irrelevant
ESIZE = DSIZE = 3
EMPTAB
JONES E D42 21,000.00
SMITH E D32 14,000.00
LORIN E D42 10,000.00

DEPTTAB
D42 10,000.00
D32 8,000.00
D95 10,000.00

ERRCODE = 1
ESIZE, DSIZE, EMPTAB, and
DEPTTAB are unchanged
ERRCODE = 2
ESIZE, DSIZE, and DEPTTAB are
unchanged
EMPTAB
JONES E
D42 21,100.00
SMITH E
D32 14,000.00
LORIN E
D42 10,200.00

5-4
5-4 5-2

75

5-3
18 5-3
ERRORCODE=0 2 ESIZE=0
DSIZE=0
5-4

/ 5-4

Jones Lorin
16 18
5-3

16 CODE(K)=MGR

5-2 6913 21 2 16
4

5-5

5-2
Decision

Condition

True Outcome

False Outcome

ESIZE 0

ESIZE 0

ESIZE > 0

DSIZE 0

DSIZE 0

DSIZE > 0

SALES (I) MAXSALES

Will always occur at least


once.

Order DEPTTAB so that a


department With lower sales occurs
after a department with higher sales.

SALES (J) = MAXSALES

Will always occur at least

All departments do not have the same

76

sales.

13

EMPTAB.DEPT(K) =
DEPTTAB.DEPT(J)

There is an employee

There is an employee who in an


eligible is not in an department.
Eligible department.

16

SALARY (K)
LSALARY

An eligible employee earns


LSALARY or more.

An eligible employee earns less than


LSALARY.

16

CODE (K) = MGR

An eligible employee is a
manager.

An eligible employee is not a


manager.

21

-FOUND

An eligible department
contains no employees.

An eligible department contains at


least one employee.

once.

ESIZE = 0 DSIZE = 0

ERRCODE = 1

All other inputs are irrelevant

ESIZE, DSIZE, EMPTAB, and


DEPTTAB are unchanged

ESIZE = 0 DSIZE > 0

Same as above

All other inputs are irrelevant


3

ESIZE > 0 DSIZE = 0


All other inputs are irrelevant
ESIZE =5 DSIZE = 4
EMPTAB
JONES M D42 21,000.00
WARNS M D95 12,000.00
LORIN E D42 10,000.00
TOY
E D95 16,000.00
SMITH E D32 14,000.00

Same as above

DEPTTAB
D42 10,000.00
D32 8,000.00
D95 10,000.00
D44

10,000.00

ERRCODE = 2
ESIZE, DSIZE, and
are unchanged
EMPTAB
JONES M D42
WARNS M D95
LORIN E D42
TOY
E D95
SMITH E D32

DEPTTAB
21,100.00
12,100.00
10,200.00
16,100.00
14,000.00

5-5
BONUS

ERRORCODE 0 1
LSALARY $150,000.01
16 SALARY(K)> LSALARY SALARY(K)>= LSALARY

77

off-by-one DEPTTAB
EMPTAB

5-5 BONUS

PL/1 BONUS 5 EMPTABDEPTTABESIZEDSIZE


ERRORCODE
DECLARE 1 EMPTAB(*), /*INPUT AND OUTPUT*/
2 NAME CHARACTER(6),
2 CODE CHARACTER(1),
2 DEPT CHARACTER(3),
2 SALARY FIXED DECIMAL(7,2);
DECLARE 1 DEPTTAB(*), /*INPUT*/
2 DEPT CHARACTER(3),
2 SALES FIXED DECIMAL(8,2);
DECLARE (ESIZE, DSIZE) FIXED BINARY; /*INPUT*/
DECLARE ERRCODE FIXED DECIMAL(1); /*OUTPUT*/

ESIZEDSIZE EMPTABDEPTTAB
EPTABDEPTTAB
DEPTTABSALESEMPTAB
SALARY$150,000
EMPTAB.CODE=M,$1,000$2,000
EMPTAB.SALARY ESIZEDSIZE 0
ERRCODE 1
ERRCODE
2 0

1. EMPTAB 1
2. EMPTAB 65 535
3. EMPTAB 0
4. DMPTAB 1

78

5. DMPTAB 65 535
6. DMPTAB 0
7. 1
8. 65535
9.
10. DEPTTAB
11. DEPTTAB
12. DEPTTAB
13. EMPTTAB
14. EMPTTAB
15.
16.
17. $149 999.99
18. $150 000
19. $150 000.01

20. ERRCODE0
21. ERRCODE1
22. ERRCODE2
23. $299 999.99

24. DEPTTAB

ERRCODE=2

24 25 8

21
5-5

79

l4710141718192023 24 5-5

11
5-5 4

5-5
5-6
5 71014171819 20 6 l4
23 7 24
5-6
BONUS

ESIZE = 3 DSIZE = 2
EMPTAB
ALLY
E D36 14,999.99
BEST
E D33 15,000.00
CELTO E D33 15,000.01
ESIZE =1 DSIZE = 1
EMPTAB
CHIEF
M D99 98,899.99
ESIZE =2 DSIZE = 2
EMPTAB
DOLE
E D67 10,000.00
WARNS E D22 33,333.33

DEPTTAB
D33 55,400.01
D36 55,400.01

DEPTTAB
D99 99,000.00

DEPTTAB
D66 20,000.00
D67 20,000.00

ERRCODE = 0
ESIZE, DSIZE, and
are unchanged
EMPTAB
ALLY
E D36
BEST
E D33
CELTO E D33
ERRCODE = 0
ESIZE, DSIZE, and
are unchanged
EMPTAB
CHIEF
M D99
ERRCODE = 2
ESIZE, DSIZE, and
are unchanged
EMPTAB
DOLE
E D67
WARNS E D22

DEPTTAB
15,199.99
15,100.00
15,100.01
DEPTTAB
99,899.99
DEPTTAB
10,000.00
33,333.33

5-6 BONUS

5.2
,

80

big-bang )

5-7 6
A BC
D B E
6

5-7 6
drive module
stub module B

81

B B E
B E B
E E
6

5-7

EC F

B D E F
B B E

1.

5-7 5
5

5
5

2.

3.

82

4.

B
E A
E A B

E A
B

5.

5-7 A A BCDE F
A BC E
F
F ABCD E F
F

6.

1 4 56

83

1 4
5 6

5.3

5.3.1

5-8 A L 12 J
I/O I I/O
A BC D

84

A B A B
A
A
A
wired-in)

5-8 12

A
BC D

85

B
C
D
B A D

A B
A B
A
B
B A

A
5-9

59

1. A
2. A

B
B

C
E

D
F

E
J

F
C

G
G

H
K

I
D

J
H

K
L

L
I
86

3. A
4. A

D
B

H
F

I
J

K
D

L
I

C
E

G
C

B
G

F
K

J
H

E
L

A
A A-B
A-C A-D

1.

2.

I/O

J I I/O
G
ABFJDICGEKHL
6 3 5-10
5-10

87

5-10 H H
H
J
J H F B A D )
H J
H 5-2 BONUS D
5-5 5-6 7
H

J H

E 5-10
I
E B

Stub E

Stub C

Stub H

5-10

88

5-8
A D

5-8 A
B
A J
A
A

5.3.2

5-8 EJGK
L I

89

D F
5-11 E B B
EF J

Drive

Drive

5-11

A
I/O I/O 511

90

5.3.3

5-3

5-3

5-3

2 I/O

1
2
3 I/O

4
5
6
7

2
3

1
2

5.4

91

5-7
7 ESIZEDSIZE DEPTTAB
ESIZEDSIZE
DEPTTAB

2-2

92

93

6-1
6-1
7
1.

2.

3.

4.

94

5.

6.

7.

6-2

95

6-2

6-3

96

6-3

6-3

97

6-3

6.1 (Function Testing)


6-3

4 FORTRAN
DIMENSION DISPLAY

98

6.2 (System Testing)

6-3

1.

2.

6-4

99

6-4
6-4

4 DISPLAY

100

15 15
15

6.2.1 (Facility Testing)

6.2.2 (Volume Testing)

101

6.2.3 (Stress Testing)

50

200 200
201

15 15

web

9
Web

102

6.2.4 (Usability Testing)

1.

2.

3.

IEK022A OPEN
ERROR ON FILE ' SYSIN ' ABEND CODE = 102 ?

4.

5.

PIN

6.

103

7.

8.

6.2.5 (Security Testing)

web

6.2.6 (Performance Testing)

104

6.2.7 (Storage Testing)

6.2.8 (Configuration Testing)

I/O

Web
Web
Web

6.2.9 //(Compatibility/Configuration/Conversion Testing)

105

6.2.10 (Installability Testing)

6.2.11 (Reliability Testing)

WANISP
99.97

MTBF

MTBF 20
12

106

SRE
6-l

SRE
6-1 /

100

8760.0

99.9

8751.2

98

8584.8

97

8497.2

96

8409.6

95

8322.0

6.2.12 (Recovery Testing)

I/O

MTTR
MTTR
MTTR

6.2.13 (Serviceability Testing)

107

6.2.14 (Documentation Testing)


6-4

6.2.15 (Procedure Testing)

6.2.16

l2

108

6.3 (Acceptance Testing)


6-3

6.4 (Installation Testing)


6-3 6-3

109

1.
2.
3.
4.

6.5

1.

2.

3.

110

4.

5.

6.

7.

web web

8.

9.

10.

11.

/
12.

111

6.6

1.

2.

l2

l23

112

70
3

1.

2.

3.

100
4-8

113

40

10,000
100 5 98
95 500
500 200 300
196 285
6-2
6-2

65

30

60

35

98

95

4 3 3

1.

130 200
65

2.

240 200 30 300 60


4
240

3.

111 3

240

114

4
240

7 6-5
7

6-5

115

6-5
6-6
6
6

116

6-6

6.7
2

117

7 (DEBUGGING)

7 (DEBUGGING)

95

118

7.1 (Debugging by Brute Force)

1.

2.

3.

119

7 (DEBUGGING)

l2

7.2 (Debugging by Induction)

7-1

120

7-1

1.

2.

7-2

?
Is
What
Where
When
To what next

Is not

7-2
3.

121

7 (DEBUGGING)

4.

51 73.2
26 82
7-3
?
What
Where

Is
3

When

51

To what next

26
1

Is not

2 200

7-3

26
51l 1 51

26

122

7.3 (Debugging by Deduction)

7- 4

7-4

1.

2.

7-2

3.

123

7 (DEBUGGING)


4.

4 DISPLAY
38 4

0000 4444
8888 CCCC

23FC23FD23FE 23FF C
7-5

0
E 14
4 16

DISPLAY

0000 = 0000 4444 8888 CCCC

M1
INVALID
SYNTAX

DISPLAY 21v-29

0000020 0000 4444 8888 CCCC

000020 = 4444 8888 CCCC 0000

DISPLAY.11

000010 = 0000 4444 8888 CCCC


000010 = 0000 4444 8888 CCCC

000000 = 0000 4444 8888 CCCC

DISPLAY 8000-END

M2 STORAGE REOUESTED IS 008000 = 0000 4444 8888 CCCC


BEYOND ACTUAL MEMORY
LIMITS

COMMAND

7-5 DISPLAY

1.

DISPLAY

2.

3.

124

4.

7-5 1
2 3
4

AF

7FFF

07FFF

32 16
11

8000
1F40
21 29 15
ID

125

7 (DEBUGGING)

7-5

7.4 (Debugging by Backtracking)

7.5 (Debugging by Testing)

/
/

126

7.6

7.6.1
1.

2.

30

3.

4.

127

7 (DEBUGGING)

5.

7.6.2
1.

2.

3.

100%

4.

128

6 l
5.

6.

7.

12

7.7

129

7 (DEBUGGING)

IF

60 10
3

130

8
20 90 XPExtreme Programming
Kent Beck
1996
XP
XP

XP JavaVisual Basic C#
CC++
FORTRAN COBOL

C# Java API

XP

XP

XP
XTExtreme Testing

8.1
XP

131

XP
XP

XP

XP

XP

XP

XP
5 XP
XP 12 8-l
12 XP 4
1.

2.

3.

4.

8-l
XP

132

XP
XP

8-1 12

1.

2.
3.
4.

5.

6.

7.

8.

9.
10. 40

11.

12.

40

XP

133

XP 12 XP
XP
1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.
12.
XP XP
12
XP
XP

XP
XP
XP

134

8.2
XP

8.2.1

XP

135

5
JavaC#Visual Basic

8.2.2
XP
/

136

8.3
Java JUnit Java

check4Primo.java test harness )


check4PrimeTestjava A

n0<=n<=1000 n
n
n

XP 5

8.3.1

137

8 -2 8

8 -2 check4Prim.java

n=3

n=1,000

3
4
5

n=0
n=-1
n=1,001

6
7
8

n=a
n

8-2 1
B
1,000
2

3
2
0
4 5 0

138

1000
6
Jova

7 8 t1

JUnit Java
Kent Beck Erich Gamma JUnit
JUnit

JUnit JUnit
API XP JUnit

www.JUnit.org

8.3.2

check4primeTest 8-3 check4PrlmoTest JUnit

8 -3

testCheckPrime_true()
1
testCheckPrime_false()
2,3
testCheck4Prime_checkArgs_char_input()
7
testCheck4Prime_checkArgs_above_upper_bound() 5
testCheck4Prime_checkArgs_neg_input()
4
testCheck4Prime_checkArgs_2_inputs()
6

139

testCheck4Prime_checkArgs_0_inputs()

testCheckPrime_false()

public void testCheckPrime_false(){


assertFalse(check4prime.primecheck(0));
assertFalse(check4prime.primecheck(1000));
}
A check4JavaTest
JUuit
JUnit assertFalse()
false"

assertFalse()

check4prime.primecheck(0)

public class check4prime{


public static void main(string[] args)
public void checkArgs(string[] args) throws Exception
public boolean primeCheck(int num)
}
java check4Prime
Java main()
checkArgs() n 0<=n<=1000Primecheck()
Eratosthenes

140

8.4

141

black-box testing

bottom-up testing

boundary-value analysis
t

branch coverage
cause-effect graphing

code inspection

condition coverage

data-driven testing
decision/condition coverage

decision coverage

desk checking

equivalence partitioning

exhaustive input testing

external specification

facility testing

142

function testing
incremental testing

input/output testing 11
logical-driven testing

multi-condition coverage

nonincremental testing

performance testing

random-input testing

security testing

stress testing

system testing

testing
top-down testing

usability testing

volume testing

walkthrough

white-box testing
__END__

143