Professional Documents
Culture Documents
Software Testing and Quality Assurance - Chapter 04 - Test Design
Software Testing and Quality Assurance - Chapter 04 - Test Design
Software Testing and Quality Assurance - Chapter 04 - Test Design
Test Design
AHMED A. QAZZAZ OCT 2021
Index
• Test Design
• Test Case
• White Box Testing
• Branch Coverage
• Statement Coverage
• Mutation testing
Test Design
is a process that describes “how” testing should be done
A test design basically helps us to select a good set of tests from the total number of all possible tests for a
given system
Following are the typical design techniques in Dynamic testing:
1. Deriving test cases directly from a requirement specification or black box test design technique. The Techniques
include:
•Boundary Value Analysis (BVA)
•Equivalence Partitioning (EP)
•Decision Table Testing
•State Transition Diagrams
Use Case Testing
Precondition:
Postcondition:
• Test case Id: String of letters and numbers that uniquely identify this test case document
• For example: c_01.1, c_01.1a, c_01.2,…
Test Case Document Details
• Module Name: Mention name of main module or sub module you want to write the test cases.
• For Examples
• Authentication
• Products Filter
Test Case Document Details
• Test Designed By: test’s name.
• For example: Mohamed Ahmed
Test Case Document Details
• Test Executed By: Name of tester who executed this test. To be filled after test execution.
• For example: Mohamed Ahmed
Test Case Document Details
• Preconditions: which describe the state of the software before the test case. It is the settings/
conditions required to execute the test case.
• For Example: Software should be install on system, login page should be available on
desktop.
Test Case Document Details
• Step: describes the step sequence
• Action: Actions that describe the specific steps which make up the interaction.
It describes in a detailed sequence what have to be done in order to achieve the test case
results.
• For example: Enter login name less than 3 chars (i.e. “a”) and password and click Submit
button
Test Case Document Details
• Expected Results which describe the expected state of the software after the test case is
executed. Describe the expected result in detail including message/error that should be
displayed on screen.
• For example:
• an error message “Login not less than 3 characters” must be displayed
Test Case Document Details
• Actual Results which describe the actual state of the software after the test case is executed.
• The actual result of the test; to be filled after executing the test.
Test Case Document Details
• Post-condition: What should be the state of the system after executing this test case?
• For example: The user will login inside the app.
Example
White Box Testing
Control Flow Testing
• structural testing strategy that uses the program’s control flow as a model
• Control-flow testing techniques are based on wisely selecting a set of test paths through the
code
Control Flow Testing
• Test cases examples
Control Flow Testing
• in the previous code the number of possible test cases is 264, Assuming that integer is 32 bit
• Exhaustive testing is very hard.
• This {(x=3,y=2),(x=4,y=3),(x=5,y=1),{(x=100,y=99)} test cases set has more cases but it will not
detect the error.
Control Flow Graph
• Control graph will consists of three primitives:
• decisions
• junctions
• process block
Decision
• is a program point at which the control can diverge, (e.g., if and case statements).
S1 S2 S1
C
for loo
for i = 1 to n do s
S S1
while C do S1
Example
B1
B3 B2 B3 B2
B4
B4
AHMED A. QAZZAZ OCT 2021
Example.2
B1
B2
B3
B4
B5
B6
AHMED A. QAZZAZ
B7 OCT 2021
Example.2
B1 B2 B3 B4 B5 B6 B7
B1
B2
B3
B4
B5
B6
B7
B8
AHMED A. QAZZAZ OCT 2021
Example.3 - Test cases
• lets try to call
• check2(3, 2)
check2(3,2) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
2
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
2
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
2
Example.3 - Test cases
• lets try to call
• check2(2,4)
check2(2,4) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
4
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
4
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s=0
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
6
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 11
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 27
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 27
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 27
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
check2(2,3) test case#1 B1
B2 x=
y=
d=
B3
s = 27
B4
B5 B6
B7
B8
AHMED A. QAZZAZ OCT 2021
8
Results
• Problem: node 6 is never executed, so we don’t have 100% branch coverage or statement
coverage
• Note d is 0 which means statement
• d= d+x-y;
• Code that has not been executed during testing is more likely to contain errors
Branch Coverage
• write test cases that cover all branches of decision nodes
• True and false branches of each IF
• The two branches corresponding to the condition of a loop
• All alternatives in a SWITCH
Branch coverage
• We need to cover all the nodes with branches 1,2,6 1 6 8
and 8 for both True and False branches
2 7
3 9
5 10
AHMED A. QAZZAZ OCT 2021
Branch Coverage
• We need to cover the paths through the nodes 1-3-5-6 in both cases for node 3
• abc
• adc
1 3 5 6
a b c
Branch Coverage
• We need to cover the paths through the nodes 1-3-5-6 in both cases for node 3
• abc
PATH NODE 3 INPUT(X) OUTPUT
• adc
negative
d ABC TRUE 2
integer -2
1 3 5 6
a b c
positive
ADC FALSE 2
integer 2
AHMED A. QAZZAZ OCT 2021
Statement Coverage
• write test cases that cover all nodes 1 6 8
• We need to cover all the nodes from 1, to 10
2 7
3 9
5 10
AHMED A. QAZZAZ OCT 2021
Statement Coverage
• We need to cover all nodes by checking that each link is covered at least once
• links are: a, b, c, and d
1 3 5 6
a b c
Statement Coverage
• We need to cover the paths through the nodes 1-3-5-6 in both cases for node 3
• abc Links Test Cases
Path
• adc a b c d Input(x) Output
abc ✓ ✓ ✓ -2 2
d adc ✓ ✓ ✓ 2 2
1 3 5 6
a b c
EXAMPLE
True True
a b c d e
1 3 4 5 6 2
h f
i g
l k j
10 9 8 7
True True
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
-
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
a, b, c, d, f, m
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
a, b, c, d, f, m, i, b, c, d, e
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
a, b, c, d, f, m, i, b, c, d, e
a, b, h
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
a, b, c, d, f, m, i, b, c, d, e
a, b, h, k, g, d, e
i
h
g
f 4, 6, 7, and 9
l k j
10 9 8 7 Paths
True True
a, b, c, d, e
a, b, c, d, f, j, g, d, e
a, b, c, d, f, m, i, b, c, d, e
a, b, h, k, g, d, e
a, b, h, l, i, b, c, d, e
AHMED A. QAZZAZ OCT 2021
Results
Decision Nodes
Other Nodes
a
2 b
3
True
c
4 d
m e
f g
5 6
h
i j
7 8
1
2 k
3 9
4
5 l
6
7
8
9
AHMED A. QAZZAZ OCT 2021
True
empty
abcd ✓ ✓ ✓ ✓ T T FALSE “”/“a@b.c” “123”/“”
error
abefg ✓ ✓ ✓ ✓ ✓ T F T FALSE “abc” any value email error
abehij ✓ ✓ ✓ ✓ ✓ ✓ T F F T FALSE “ab@aa.com” “123” pass error
abehkl ✓ ✓
AHMED A. QAZZAZ ✓ ✓ ✓ ✓ T F F F FALSE “ab@aa.com“ “a12345A” request
OCT 2021
Example
• Classify triangles by the length of the side
5
6
7
AHMED A. QAZZAZ OCT 2021
Example
True
b d f h
a c e g i j
1 2 3 4 5 6 7
False
ab ✓ ✓ T 0 0 0 4
acd ✓ ✓ ✓ F T 1 1 3 4
acef ✓ ✓ ✓ ✓ F F T 2 2 2 1
acegh ✓ ✓ ✓ ✓ ✓ F F F T 2 2 3 2
acegij ✓ ✓ ✓ ✓ ✓ F F F F 2 3 4 3
AHMED A. QAZZAZ OCT 2021
Check this Mistake
• if we type a*b instead of a + b in the second condition by mistake or internally.
• by using the previous test cases we will not be able to detect this mistake
• So we need to add new test case such as (1,1,1) it will give invalid while the expected is
equilateral.
Mutation Test
• Mutation is a small change to a program
• Mutation test based on creating faults to script, and check it the test cases can detect these
faults or not.
• Randomly make changes to the script
Example
a = 6, b = 1 result = 1 result = 1
a = 1, b = 6 result = 1 result = 6
Mutations
Process
Mutation Test
Mutation
Mutation TEST New data
Mutation
YES
Kill mutant when its behavior
differ from the original any
process n mutant Complete
at i o NO
u t alive ?
M
AHMED A. QAZZAZ OCT 2021
Mutation Score
• The mutation score for a set of test cases is
• mutationScore = 100 * D / (N - E)
• D : Dead mutants
• N : Number of mutants
• E : Number of Equivalent mutants
• When score is 100% the mutations are adequate.
Equivalent mutants
• Mutants that can not be killable