Lecture - Software Testing and Applications
Lecture - Software Testing and Applications
Software Testing
&
Applications, Tools and Technologies
The program reads three integer values from an input dialog. The three
value represent the lengths of the sides of a triangle. The program
displays a message that states whether the triangle is scalene,
isosceles, or equilateral.
1
04/03/2017
Solution?
Tester Action and Data Expected Result
Erroneous input partition
a, b, or c a non-number an error message
2
04/03/2017
Why Testing?
Testing Purpose
1. Avoid Redundancy
Source Code
Requirement/Design/Maintenance/Change
Management
2. Reducing Cost
Cost of detection, Cost of Prevention
Internal Failure (at the time of development or before
you release the software product)
External Failure (finding bugs after deploying the
software product)
3. Correctness CONFIDENCE
4. Quality Assurance
3
04/03/2017
Trivial example
Taxonomy of Bugs
Verification?
Error?
Validation?
Defects ? Doesnt work as defined
Fault?
Failure?- Non functioning of system
Quality?
4
04/03/2017
BUG
Bugs
5
04/03/2017
and now Fault is there till you will not reach the Mumbai, but
when you reach Mumbai that is a final stage which is called
"Failure" because you had to reach Delhi but now you are in
Mumbai.
A mistake in coding is called Error, error found by tester is called
defect, defect accepted by development team then it is called bug, build
does not meet the requirements then it Is failure.
6
04/03/2017
A tester does not necessarily have access to the code and may be just
testing the functionality of the program. In that case the tester will
realize the output is faulty and will raise a defect.
7
04/03/2017
...testing can be a very effective way to show the presence of bugs, but
is hopelessly inadequate for showing their absence. The only effective
way to raise the confidence level of a program significantly is to give a
convincing proof of its correctness.
Edsger Dijkstra
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD03xx/EWD340.html
Developer
Independent Tester
Understands the system but, Must learn about the
will test "gently and, is driven system, but, will attempt to
by "delivery" break it and, is driven by
quality
8
04/03/2017
5^15 = 30517578125!!!
9
04/03/2017
Software Testing
Techniques
19
Testing Strategy
Black-box White-box
(Specification based) Static Analysis
(Code based)
Requirement
Design
Equivalence class Boundary Value Cause-Effect Implementation
Partitioning Analysis Graphing
20
10
04/03/2017
2. Logical Expressions
(not X or not Y) and A and B
A: {0, 1, >1}
3. Input Domain B: {600, 700, 800}
Characterization C: {swe, cs, isa, infs}
if (x > y)
z = x - y;
4. Syntactic Structures else
z = 2 * x;
11
04/03/2017
Black-box Testing
Inputs causing
anomalous
Input test data I behaviour
e
System
24
12
04/03/2017
25
A Set of Guidelines
If an input condition specifies a range of values (e.g., the item count can
be from 1 to 999), identify one valid equivalence class (1<item count<999)
and two invalid classes (item count <1 and item count >999)
If an input condition specifies the number of values (e.g., one through six
owners can be listed for the automobile), identify one valid equivalence
class and two invalid equivalence classes (no owners and more than six
owners)
13
04/03/2017
27
Example
Example:
3 Test Cases
28
14
04/03/2017
Example
29
30
15
04/03/2017
The test case, XYZ, 0, expressing two error conditions (invalid book
type and amount) will probably not exercise the check for the
amount.
(Program may say XYZ is UNKNOWN BOOK TYPE, and not bother
to examine the remainder of the input.
31
Question?
Equivalence Class W F
E1 Non-null Exists, not empty
E2 Non-null Does not exist
E3 Non-null Exists, empty
E4 Null Exists, not empty
E5 Null Does not exist
E6 Null Exists, empty
32
16
04/03/2017
Question?
33
Boundary-Value Analysis
34
17
04/03/2017
3 11
4 7 10
9999 100000
10000 50000 99999
Less than 10000 Between 10000 and 99999 More than 99999
Input values
35
Example 1
Suppose you have very important tool at office, accepts valid User
Name and Password field to work on that tool, and accepts
minimum 8 characters and maximum 12 characters. Valid range 8-
12, Invalid range 7 or less than 7 and Invalid range 13 or more than
13.
Write Test Cases for Valid partition value, Invalid partition value and
exact boundary value.
36
18
04/03/2017
37
Exercise??
38
19
04/03/2017
White-Box Testing
39
White-Box Testing
20
04/03/2017
Control-flow-based Testing
Control-flow-Graph
21
04/03/2017
Elements of a CFG
..
22
04/03/2017
Example
switch (position)
case CASHIER
if (empl_yrs > 5)
bonus := 1;
else
bonus := 0.7; .
case MANAGER .
.
bonus := 1.5;
if (retiring_soon) .
bonus := 1.2 * bonus
case
endswitch
while (c) {
23
04/03/2017
Example
1
2
3 4
5
6
24
04/03/2017
Statement coverage
write enough test cases to execute every statement at least once
Example
25
04/03/2017
Example
Example
Test Cases:
1) A = 1, B = 0, X = 3 (abe)
2) A =2, B = 1, X = 1 (abe)
26
04/03/2017
Exercise
Exercise
27
04/03/2017
28
04/03/2017
Junit, In PICTURES
29
04/03/2017
A Simple Example
Suppose you have a class Arithmetic with methods int multiply(int x, int y), and
boolean isPositive(int x)
import org.junit.*;
import static org.junit.Assert.*;
@Test
public void testMultiply() {
assertEquals(4, Arithmetic.multiply(2, 2));
assertEquals(-15, Arithmetic.multiply(3, -5));
}
@Test
public void testIsPositive() {
assertTrue(Arithmetic.isPositive(5));
assertFalse(Arithmetic.isPositive(-5));
assertFalse(Arithmetic.isPositive(0));
}
}
30