Software Quality Assurance & Testing: Assignment: 02 Submitted by Kanok Chanpa Saha Bhowmik ID-201120

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

Software Quality Assurance & Testing

Assignment: 02

Submitted by
Kanok Chanpa Saha Bhowmik
ID-201120
Calculator Test Case for two variable

Addition for two variable


Line Number Program CFG
1 public int add(int a, int b) { A
2 return a+b;
3 } 1,2,3

Multiple Condition Coverage


Test case Number a b Result
1 1000 1000 2000
2 1000 -2147483649 Invalid Input
3 -2147483649 1000 Invalid Input
4 2147483648 2147483648 Invalid Input

Independent Path Testing


Test case a b Expected Independent
Number Result Paths Covered
by Test Case
5 1000 1000 2000 A

Data Flow Testing


Test case Pattern Line Number Explanation
Number
6 ~d 1 Normal Case, Allowed

7 uk 2 Normal Case, Allowed

8 K~ 3 Normal Case, Allowed

Mutation Testing
Test case a b Initial program Mutation Result
Number result
9 2 2 4 0 (Line#2: return a-b)
10 4 3 7 12 (Line#2: return a*b)
11 3 2 5 4 (Line#2: return a+1)
12 5 2 7 3 (Line#2: return b+1)

Subtraction for two variable


Line Number Program CFG
1 public int subtract(int a, int A
b) {
2 return a-b; 1,2,3
3 }

Multiple Condition Coverage


Test case Number a b Result
13 1000 1000 0
14 1000 -2147483649 Invalid Input
15 -2147483649 1000 Invalid Input
16 2147483648 2147483648 Invalid Input

Independent Path Testing


Test case a b Expected Independent
Number Result Paths
Covered by
Test Case
17 1000 1000 0 A

Data Flow Testing


Test case Number Pattern Line Number Explanation
18 ~d 1 Normal Case,
Allowed
19 uk 2 Normal Case,
Allowed
20 K~ 3 Normal Case,
Allowed
Mutation Testing
Test case a b Initial program Mutation Result
Number result
21 2 2 4 0 (Line#2: return a-b)
22 4 3 7 12 (Line#2: return a*b)
23 3 2 5 4 (Line#2: return a+1)
24 5 2 7 3 (Line#2: return b+1)

Multiplication for two variable


Test case Number Program CFG
1 public int Multiply(int a, int A
b) {
2 return a*b; 1,2,3
3 }

Multiple Condition Coverage


Test case Number a b Result
25 1000 1000 1000000
26 1000 -2147483649 Invalid Input
27 -2147483649 1000 Invalid Input
28 2147483648 2147483648 Invalid Input

Independent Path Testing


Test case a b Expected Independent
Number Result Paths
Covered by
Test Case
29 1000 1000 1000000 A

Data Flow Testing


Test case Number Pattern Line Number Explanation
30 ~d 1 Normal Case,
Allowed
31 uk 2 Normal Case,
Allowed
32 K~ 3 Normal Case,
Allowed
Mutation Testing
Test case a b Initial program Mutation Result
Number result
33 2 2 4 0 (Line#2: return a-b)
34 4 3 12 7(Line#2: return a+b)
35 3 2 6 4 (Line#2: return a+1)
36 5 2 10 3 (Line#2: return b+1)

Division for two variable


Test case Number Program CFG
1 public int divide(int a, int b) A
{
2 return a/b; 1,2,3
3 }

Multiple Condition Coverage


Test case Number a b Result
37 1000 1000 1
38 1000 -2147483649 Invalid Input
39 -2147483649 1000 Invalid Input
40 2147483648 2147483648 Invalid Input

Independent Path Testing


Test case a b Expected Independent
Number Result Paths
Covered by
Test Case
41 1000 1000 1 A

Data Flow Testing


Test case Number Pattern Line Number Explanation
42 ~d 1 Normal Case, Allowed
43 uk 2 Normal Case, Allowed
44 K~ 3 Normal Case, Allowed

Mutation Testing
Test case a b Initial program Mutation Result
Number result
45 2 2 4 4 (Line#2: return a+b)
46 4 3 7 1 (Line#2: return a-b)
47 3 2 5 4 (Line#2: return a+1)
48 5 2 7 3 (Line#2: return b+1)

Addition for three variable


CFG Table
Test case Number Program CFG
1 public int add(int a, int b, int A
c) {
2 return a+b+c; 1,2,3
3 }

Multiple Condition Coverage


Test case a b c Result
Number
49 1000 1000 1000 3000
50 1000 1000 -2147483649 Invalid Input
51 1000 -2147483649 1000 Invalid Input
52 1000 2147483648 2147483648 Invalid Input
53 -2147483649 1000 1000 Invalid Input
54 2147483648 1000 -2147483649 Invalid Input
55 -2147483649 -2147483649 1000 Invalid Input
56 2147483648 2147483648 2147483648 Invalid Input

Independent Path Testing


Test case a b c Expected Independent
Number Result Paths
Covered by
Test Case
57 1000 1000 1000 3000 A

Data Flow Testing


Test case Pattern Line Number Explanation
Number
58 ~d 1 Normal Case, Allowed
59 uk 2 Normal Case, Allowed
60 K~ 3 Normal Case, Allowed

Mutation Testing
Test case a b c Initial program Mutation Result
Number result
61 2 2 4 8 0 (Line#2: return
a+b-c)
62 4 3 7 14 84 (Line#2: return
a*b*c)
63 3 2 5 10 4 (Line#2:return
a+1)
64 5 2 7 14 3 (Line#2:return
b+1)
65 7 3 5 15 6 (Line#2:return
c+1)

One Input List for Add


CFG Table
Line Number Program CFG
1. public int add(List<Integer>a) {
2. Integer temp=0; A 1,2,3
3. for (Integer num : a) {
4. temp+=num;
4,5
5. } B
6. return temp;
6,7
7. } C

Multiple Condition Coverage


Test case 1st Value 2nd Value 3rd Value Result
Number
66 1000 1000 1000 3000
67 1000 1000 -2147483649 Invalid Input
68 1000 -2147483649 1000 Invalid Input
69 1000 2147483648 2147483648 Invalid Input
70 -2147483649 1000 1000 Invalid Input
71 2147483648 1000 -2147483649 Invalid Input
72 -2147483649 -2147483649 1000 Invalid Input

Independent Path Testing


Test case a b c Expected Independent Paths
Number Result Covered by Test
Case
73 1000 1000 1000 3000 A-B-C

Data Flow Testing


Test case Pattern Line Number Explanation
Number

74 ~d 1,2 Normal Case, Allowed


75 du 3 Normal Case, Allowed
76 uu 4,5 Normal Case, Allowed
77 uk 6 Normal Case, Allowed
78 K~ 7 Normal Case, Allowed
Mutation Testing
Test case 1st 2nd 3rd Initial Program Mutant Result
Number Value Value Value Result
79 2 2 4 8 18 (Line#2: Integer
temp=10)
80 4 3 7 14 4 (Line#2: Integer
temp=-10)

GradeCalculator Class Methods Test


getGrade(int mid, int ct, int finalExam, int attendance)
For four variable

CFG Table
Line Number Program CFG
1. public String getGrade(int mid, int ct, int A
finalExam, int attendance) { 1,2,3,4
2. Int total=mid+ct+finalExam+attendance;
3. String grade = "";
B 5
4. if(total >= 80) {
5. grade = "A+";
6. } C 6
7. if(total >=70) {
8. grade = "A"; 7
D
9. }
10. if (total >= 60) { 8
E
11. grade = "B";
12. } 9
F
13. if (total >= 50) {
14. grade = "C"; 10
G
15. }
16. if (total <= 50) { H 11

17. grade = "F";


18. } 12
I
19. return grade;
20. }
13

14
K

15
L

M 16

N 17

O 18

19,20
P

Multiple Condition Coverage


Test Mid CT Final Exam Attendance Actual Expected
case Result Result
Number
81 20 20 50 10 C (100) A+ (100)
82 20 20 50 2147483648 Invalid Invalid Input
Input
83 20 20 2147483648 10 Invalid Invalid Input
Input
84 20 20 2147483648 2147483648 Invalid Invalid Input
Input
85 20 2147483648 50 10 Invalid Invalid Input
Input
86 20 2147483648 50 2147483648 Invalid Invalid Input
Input
87 20 2147483648 2147483648 10 Invalid Invalid Input
Input
88 20 2147483648 2147483648 2147483648 Invalid Invalid Input
Input
89 2147483648 20 50 10 Invalid Invalid Input
Input
90 2147483648 20 50 2147483648 Invalid Invalid Input
Input
91 2147483648 20 2147483648 10 Invalid Invalid Input
Input
92 2147483648 20 2147483648 2147483648 Invalid Invalid Input
Input
93 2147483648 2147483648 50 10 Invalid Invalid Input
Input
94 2147483648 2147483648 50 2147483648 Invalid Invalid Input
Input
95 2147483648 2147483648 2147483648 10 Invalid Invalid Input
Input
96 2147483648 2147483648 2147483648 2147483648 Invalid Invalid Input
Input

Independent Path Testing


Test Mid CT Final Attendance Expected Actual Independent Paths Covered
case Exam Result Result by
Num Test Case
ber
97 10 15 50 5 A+ (80) C (80) A-B-C-D-E-F-G-H-I-J-K-
L-M-O-P
98 10 10 50 5 A (75) C(75) A-C-D-E-F-G-H-I-J-K-L-
M-O-P
99 5 5 50 5 B (65) C (55) A-C-D-F-G-H-I-J-K-L-M-
O-P
100 0 0 50 5 C (55) C (55) A-C-D-F-G-I-J-K-L-M-O-
P
101 20 10 0 5 F(45) F(35) A-C-D-F-G-I-J-L-M-N-O-
P

Data Flow Testing


Test case Pattern Line Number Explanation
Number
102 ~d 1 Normal Case, Allowed
103 du 2 Normal Case, Allowed
104 uu 3 Normal Case, Allowed
105 uk 4 - 18 Normal Case, Allowed
106 K~ 19 Normal Case, Allowed

Mutation Testing
Test Mid CT Final Attendance Initial Expected Result
case Exam Program
Number Result
107 10 10 10 10 C (80) A+ (80)[Line#5:
return “A+”]
108 10 10 5 5 C (75) A (75) )[Line#8:
return “A”]
109 5 5 5 5 C (65) B (65) )[Line#11:
return “B”]
110 0 0 5 5 C (55) C (55) )[Line#14:
return “C”]
111 20 20 5 5 F (45) F (45) )[Line#17:
return “F”]

GetGPA(String grade) for One Input Variable

CFG Table
Line Number Program CFG
1. public double getGPA(String grade) { A
2. double gpa = 0.0; 1,2,3
3. if(grade == "A+") {
4. gpa = 4.00; B 4
5. }
6. if(grade == "A") { C 5
7. gpa = 3.50;
8. } 6
D
9. if(grade == "B") {
10. gpa = 3.00; 7
E
11. }
12. if(grade == "C") { 8
F
13. return 2.00;
9
14. } else { G

15. gpa = 0.0;


10
16. }
17. return gpa;
H 11
18. }

J
I 12

K 13 N

16
14
L

17,18
M 15
O
Multiple Condition Coverage
Test case grade Expected Result Explanation
Number
112 A+ 4.00 Normal Case, Allowed
113 A 3.50 Normal Case, Allowed
114 B 3.00 Normal Case, Allowed
115 C 2.00 Normal Case, Allowed
116 F 0.00 Normal Case, Allowed
117 G Invalid Input Invalid Input

Independent Path Testing


Test case grade Expected Result Actual Result Independent Paths
Number Covered by Test Case
118 A+ 4.00 0.00 A-B-C-D-F-G-I-K-M-
N-O
119 A 3.50 0.00 A-C-D-E-F-G-I-K-M-
N-O
120 B 3.00 0.00 A-C-D-F-G-H-I-K-M-
N-O
121 C 2.00 2.00 A-C-D-F-G-I-J-K-M-N
122 F 0.00 0.00 A-C-D-F-G-I-K-L-M-N

Data Flow Testing


Test case Pattern Line Number Explanation
Number
123 ~d 1,2 Normal Case, Allowed
124 uu 3-12 Normal Case, Allowed
125 uk 13 Normal Case, Allowed
126 uu 14-16 Normal Case, Allowed
127 uk 17 Normal Case, Allowed
128 K~ 18 Normal Case, Allowed

Mutation Testing
Test case grade Initial Program Result Mutant Result
Number
129 A+ 0.00 4.00 (return 4.00)
130 A 0.00 3.50 (return 3.50)
131 B 0.00 3.00 (return 3.00)
132 C 2.00 2.00 (return 2.00)
133 F 0.00 0.00 (return 0.00)

You might also like