Академический Документы
Профессиональный Документы
Культура Документы
What is Testing
It has been said that "approximately 50% of the elapsed time and over 50% of the total cost are expended in testing a program or system being developed. In the simplest terms, Software Testing amounts to observing the execution of a software system to validate whether it behaves as intended and identify potential malfunctions. [IEEE]
What is Testing
Testing is the process of executing a program or system with the intent of finding errors.
Myers Art of Software Testing
Testing is the process of establishing confidence that a program or system does what it is supposed to.
Hetzel 1973
What is Testing
Software Testing is the Process of Exercising or evaluating a system by manual or automated means to verify that it satisfies specified requirements or to identify differences between expected and actual results. IEEE Standard Glossary 1983
Test Cases
A very good view of testing is that it is the determination of the extent of program behavior that is both specified and implemented What can a tester do to make the region where these sets all intersect be as large as possible? How the test cases in the set T are identified?.
For example, consider a program that add two numbers, entered by the user. Each number is of one or two digits. The program shall read the inputs and print the sum. Press <enter> after each number.
1.
2.
99 + 99
-99 +(-99)
198
-198
Largest pair of numbers the program can add The specification did not say we cannot use negative numbers.
4. 5. 6. 7. 8. 9.
61 155 18 0 23 -78
Remember: A best tester is not the one who finds the most bugs
X
100 100 100 100 1
Y
100 100 100 1 1
Z
1 2 200 100 1
6
7 8 9
1
2 100 100
2
199 199 200
100
200 200 2
Not a triangle
Scalene Scalene Not a triangle
10
11 12
100
100 199
200
2 100
200
200 100
Conclusion
When one tests a program, one wants to add some value to the program. Adding value means raising the quality or reliability of the program. Raising the reliability of the program means finding and removing errors. Therefore, one should not test the program to show that it works; rather, one should start with the assumption that the program contains errors and then test the program to find as many of the errors as possible. Does testing implies that it is destructive process of trying to find the errors ?
an indication of quality
Conclusion
"Bugs lurk in corners and congregate at boundaries
Boris Beizer
OBJECTIVE CRITERIA
Papers to Study
J.A. Whittaker, What is software testing And why is it so hard?, IEEE software, January / February, 7077, 2000. J.L. LIONS et. al., Report of the enquiry board constituted by Director General of ESA for the identification of the causes of failure, www.esrin.esa.it, July 19, Paris, 1996.
Definitions
Error
People make errors. A good synonym is mistake. When people make mistakes while coding, we call these mistakes bugs.
Errors tend to propagate; a requirements error may be magnified during design and amplified still more during coding.
Error
Typographical error
Misreading of a specification
Fault
A fault is the result of an error. It is more precise to say that a fault is the representation of an error, where representation is the mode of expression, such as
narrative text dataflow diagrams hierarchy charts source code, and so on.
Failure
A failure occurs when a fault executes. A particular fault may cause different failures, depending on how it has been exercised.
Incident
When a failure occurs, it may or may not be readily apparent to the users. An incident is the symptom(s) associated with a failure that alerts the user to the occurrence of a failure
Test
A test is the act of exercising software with test cases. A Test has two distinct goals
To find failures or To demonstrate correct execution
Test Case
A test case has an identity and is associated with a program behavior. It has a set of inputs and a list of expected outputs.
Inputs
Preconditions
Outputs Post Conditions
Actual Inputs
Actual Outputs
Date
Result
Version
Run By
error
Error
Error
Fault Isolation
What is Testing
Software Testing is the Process of Exercising or evaluating a system by manual or automated means to verify that it satisfies specified requirements or to identify differences between expected and actual results. IEEE Standard Glossary 1983
Testing Principles
Testing Shows Presence of Defects
Testing can show that defects are present, but cannot prove that there are no defects. Testing reduces the probability of undiscovered defects remaining in the software but, even if no defects are found, it is not a proof of correctness.
Exhaustive Testing Testing everything (all combinations of inputs and preconditions) is not feasible except for trivial cases. Instead of exhaustive testing, we use risks and priorities to is Impossible
focus testing efforts.
Early Testing
Testing activities should start as early as possible in the software or system development life cycle and should be focused on defined objectives.
Testing Principles
Defect Clustering
A small number of modules contain most of the defects discovered during prerelease testing or show the most operational failures. If the same tests are repeated over and over again, eventually the same set of test cases will no longer find any new bugs. Tb overcome this 'pesticide paradox', the test cases need to be regularly reviewed and revised, and new and different tests need to be written to exercise different parts of the software or system to potentially find more defects.
Pesticide Paradox
Testing is done differently in different contexts. For example, safety-critical Testing is the Context Dependent software is tested differently from an . e-commerce site.
Finding and fixing defects does not help if the system built is unusable and does not fulfill the users' needs and expectations
It is difficult, due to following four reasons: 1. The number of possible input is very large. 2. The number of possible output is very large 3. The number of paths through the software is very large 4. The software specification is very subjective
How many test cases does it take to fully cover, or exercise, the source code? There are 2n 1 ways, where n is the number of conditions in the statement If the n is moderately large, imagine the number of test cases required to test the program For example, to test a clock application, How many test cases are required to test different times in a day?
12 hours x 60 minutes x 60 seconds x 2 am/pm for a total of 86,400 different input values. Thats just the valid values
Limitations of Testing
We want to test everything before giving the software to the customers. What do we understand, when we say everything? We may expect one, two or all of the following when we refer to everything:
(i) Execute every statement of the program (ii) Execute every true and false conditions (iii) Execute every condition of a decision node (iv) Execute every possible path (v) Execute the program with all valid inputs (vi) Execute the program with all invalid inputs
Limitations of Testing
It is impossible to achieving these six objectives due to time and resource constraints as We may achieve few of them with limited coverage. If we do any compromise, we may miss a bug. Hence Everything is impossible and we have to settle for less than everything in the real life situations.
Functional Testing
Black-Box Testing
requirements
output
input
events
State
c a b x
Case 2: The Previous Date Function Boundary Value Analysis Test cases
Adhoc Testing
Testing carried out using no recognized test case design technique. It occurs when the tester uses domain knowledge experience and information about soft spots to derive test cases Mostly intuitive and least uniform. Dependent on the abilities of the tester Also known as Special value testing/hacking, /outof-box testing,/ guerilla testing
The use of Equivalence Classes as the basis for Functional Testing has two motivations : We would like to have a sense of complete testing We would hope to avoid redundancy
They all test the same thing If one test catches a bug, the others probably will too.
If one test does not catch a bug, the others probably would not either.
Equivalent Classes
Important aspect of equivalence classes is that they form a partition of a set, where partition refers to a collection of mutually disjoint subsets when the union is the entire set. This suggest two things :
Entire set is represented provides a form of Completeness Disjointedness ensures a form of non-redundancy
The idea is to identify test cases by using one element from each equivalence class.
Input domain
Output domain
Most of the time, equivalence class testing classes of the input domain. However, equivalence classes should also be for output domain. Hence, we should equivalence classes based on input and domain.
defines
defined design output
b c
X1
d
Case 1: The Triangle Problem Equivalent Class Testing Output domain equivalence classes are:
O1={<x,y,z>: Equilateral triangle with sides x,y,z} O2={<x,y,z>: Isosceles triangle with sides x,y,z} O3={<x,y,z>: Scalene triangle with sides x,y,z} O4={<x,y,z>: Not a triangle with sides x,y,z}
DECISION TABLE
A decision table is a matrix of rows and columns, rather than a tree, that shows conditions and actions. Decision rules, included in a decision table, state what procedure to follow when certain condition exist. Thus, we can call it a policy specification tool Decision Tables are most effective when problem is one of selecting a single decision alternative or set of alternatives out of many possibilities
DECISION TABLE
The decision table technique is indicated for the application characterized by any of the following prominent if-then-else logic Logical relationships among input variables High Cyclomatic complexity Cause-and-effect relationships between inputs and outputs
DECISION TABLE
DECISION TABLE QUADRANTS
DECISION TABLE
The decision table on the next slide describes the actions taken in handling payments from patients in a medical clinic. The actions taken depend on whether the patient has medical insurance and, if so, which type. Two types of insurance coverage are identified:
basic health insurance (condition 1) and social health insurance (condition 2). . Four rules relate the combinations of conditions 1 and 2
Example
CONDITIONS DECISION RULES 1 2 3 4 Y N Y N N X X X X Y Y N
C1 Patient has basic health insurance C2 Patient has social health insurance A1 Pay amount of office call A2 Pay nothing A3 Pay full amount for services
DECISION TABLE
TITLE : The title of the decision table should clearly explain the purpose of the table CONDITION Statements : Then statements must be clear in their meaning and concise in their content RULES Each column of condition grid and action grid entries is called a rule. A rule is simply a statement that under a give set of condition, specific action must follow Number of Rules : The number of Rules which exist for a problem can be determined arithmetically as follows ; 1 Count the number of condition statements ( in this case 3) 2. Use the number arrived at in step 1 as the exponent of the number 2 3. Compute the number of rules 23 = 8
Conditions c1: a, b, c from a triangle? c2: a=b? c3: a=c? c4: b =c? Actions a1: Not a triangle a2: Scalene a3: Isosceles a4: Equilateral a5: Impossible
N ---X
Y N N N
X X X X X X X X
Conditions c1: a<b+c? c2: b<a+c? c3: c<a+b? c4: a=b? c5: a=c? c6: b=c? Actions a1: Not a triangle a2: Scalene a3: Isosceles a4: Equilateral a5: Impossible
F ------
T F -----
Decisions Rules T T T T T T T T T T T T T T F T T T T T T -- T T T T F F -- T T F F T T -- T F T F T F
T T T F F T
T T T F F F
X X X X X X X X X X X
Case ID
DT1 DT2 DT3 DT4 DT5 DT6 DT7 DT8 DT9 DT10 DT11
a
4 1 1 5 ? ? 2 ? 2 3 3
b
1 4 2 5 ? ? 2 ? 3 2 4
c
2 2 4 5 ? ? 3 ? 2 2 5
Expected O/P
Not a Triangle Not a Triangle Not a Triangle Equilateral Impossible Impossible Isosceles Impossible Isosceles Isosceles Scalene
Low
Sophistication
Boundary Value
Equivalence class
Decision table
High
Low
Sophistication
Boundary Value
Equivalence class
Decision table
Structural Testing
Structural Testing
Also called: White Box Testing Based on Source Code Can Be dynamic or static Necessary because:
Part of code not fully exercised. Section of code may be surplus to the requirements. Errors may be missed by functional requirements.
Problem: Too Many Paths There are typically many possible paths between the entry and exit of a typical software program. Every decision doubles the number of potential paths, every case statement multiplies the number of potential paths by the number of cases and every loop multiplies the number of potential paths by the number of different iteration values possible for the loop. Complete path coverage of even a simple unit is extremely difficult.
The Challenge Given that testing, like all other development activities has a limited amount of resources (time, people, equipment), the challenge is to select a set of test cases that is most likely to identify as many different potential defects as possible within those limits. To do this, we must eliminate as much redundancy as possible from the testing process while still insuring adequate test coverage.
Path Testing
Group of test Techniques This type of testing involves:
Generating a set of paths that will cover every branch in the program. Finding the set of test cases that will execute every path in this set of program paths.
Cyclomatic Complexity
Cyclomatic complexity is used to find the number of independent path through a program
Cyclomatic Complexity
Complexity is computed in one of three ways. 1. The number of regions of the flow graph correspond to the Cyclomatic complexity. 2. Cyclomatic complexity, V(G), for a flow graph, G, is defined as V(G) = E - N + 2 Where E is the number of flow graph edges, N is the number of flow graph nodes. 3. Cyclomatic complexity, V(G), for a flow graph, G, is also defined as V(G) = P + 1 where P is the number of predicate nodes contained in the flow graph G.
Cyclomatic Complexity
Calculate the Cyclomatic Complexity for the above figure and identify the independent path. 1. The number of regions = 5 2. Cyclomatic complexity, V(G), for a flow graph, G, is defined as V(G) = E - N + 2 = 10 7 + 2 = 5 3. Cyclomatic complexity, V(G), for a flow graph, G, is also defined as V(G) = P + 1 = 4+1 = 5
Cyclomatic Complexity
Cyclomatic Complexity
Risk Evaluation
1-10
11-20
21-50
greater than 50
Practice Exercise
Sample Problem Draw the flow graph for the given problem? Derive the independent paths Compute the cyclomatic complexity Prepare Test Cases
procedure average TYPE value [1..100] IS SCALAR ARRAY TYPE average, total_input, total.valid, minimum maximum, sum IS SCALAR TYPE i is INTEGER i=1; Total _input = total _valid = 0 Sum = 0 DO WHILE value[ i] <> -999 AND total_input <100 increment total_input by 1; IF value[ i] >= minimum AND value[ i] <= maximum THEN increment total_valid by 1; sum = sum+ value[ i] ELSE skip endif increment I by 1; ENDDO IF total_valid > 0; THEN average = sum /total_valid; ELSE average = -999 ENDIF
procedure average TYPE value [1..100] IS SCALAR ARRAY TYPE average, total_input, total.valid, minimum maximum, sum IS SCALAR TYPE i is INTEGER i=1; Total _input = total _valid = 0 Sum = 0 DO WHILE value[ i] <> -999 AND total_input <100 3 4 increment total_input by 1; IF value[ i] >= minimum AND value[ i] <= maximum 6 THEN increment total_valid by 1; 5 sum = sum+ value[ i] 7 ELSE skip endif increment I by 1; 8 ENDDO 9 > 0; IF total_valid THEN average = sum /total_valid; 10 ELSE average = -999 11 ENDIF 12 13
1.
Dynamic Analysis Dynamic analysis is done on the fly as the program is being executed and is based on intermediate values that result from the program execution
kk harmless but probably buggy. Did you want to be sure it was really killed ? ku- a bug. The object doesnt exist in the sense that its values is undefined or indeterminate ud usually not a bug because the language permits reassignment at almost any time. uk normal situation uu normal situation