Professional Documents
Culture Documents
Fundamentals of Testing
Critical element of SQA Reviews and other SQA activities can uncover errors but they are not sufficient
Testing Objective
developer
Understands the system but, will test gently and, is driven by delivery
independent tester Must learn about the system, but, will attempt to break it and, is driven by quality
4
Testing Principles
All tests should be traceable to customer requirements Tests should be planned long before testing begins Testing should begin in the small and progress toward testing in the large To be most effective testing should be conducted by an independent third party
Testability
It gives simply the platform for testing a software program easily
Simplicity The less there is to test, the more quickly we can test it Stability The fewer the changes, the fewer the disruptions to testing Understandability The more information we have, the smarter we will test
6
Kaner,Falk and Nguyen Attributes of good test A good test has a high probability of finding an error A good test is not redundant A good test should be best of breed A good test should neither too simple nor too complex
Testing cannot show the absence of defects, it can only show that software defects are present
7
Software Configuration includes a Software requirements Specification, a Design Specification, and source code.
A test configuration includes a Test Plan and Procedures, test cases, and testing tools.
Test Case Design Can be as difficult as the initial design. Testing can not prove correctness as not all execution paths can be tested. Testing an Engineered Product Knowing the specified function that a product has been designed to perform Knowing all internal workings of a product
A program with a structure as illustrated above (with less than 100 lines of Pascal code) has about 100,000,000,000,000 possible paths. If attempted to test these at rate of 1000 tests per second, would take 3170 years to test all paths. 10
Uses control structures of a procedural design to derive test cases Can derive test cases to ensure: all independent paths are exercised at least once. all logical decisions are exercised for both true and false paths. all loops are executed at their boundaries and within operational bounds. all internal data structures are exercised to ensure validity. 1. Basis Path Testing 2. Control Structure Testing
12
Arrows called edges represent flow of control Circles called nodes represent one or more actions. Areas bounded by edges and nodes called regions. A predicate node is a node containing a condition
14
1 2 3 6 7 9 10 8 5 9 4 7 6
2,3 4,5
10
11
11
Flow Chart
Flow Graph
15
Cyclomatic Complexity The Cyclomatic complexity gives a quantitative measure of the logical complexity. This value gives the number of independent paths in the basis set, and an upper bound for the number of tests to ensure that each statement is executed at least once. An independent path is any path through a program that introduces at least one new set of processing statements or a new condition (i.e., a new edge) Cyclomatic Complexity of can be calculated as: 1. Number of regions of flow graph. 2. #Edges - #Nodes + 2 3. #Predicate Nodes + 1
Continued
16
Independent Paths a) 1, 8 c)1, 2, 4, 5, 7a, 7b, 1, 8 b)1, 2, 3, 7b, 1, 8 d)1, 2, 4, 6, 7a, 7b, 1, 8
17
18
19
Graph Matrices
Graph Matrix is square with #sides equal to #nodes Rows and columns correspond to the nodes Entries correspond to the edges. Can associate a number with each edge entry. Use a value of 1 to calculate the Cyclomatic complexity For each row, sum column values and subtract 1. Sum these totals and subtract 1.
Continued
20
21
1 1 2 3 4
3 1
Connections
1-1 = 0
1 1 1 1
1 1
1 a 3 b 5 f 4 g 2 c d
Graph Matrix
Cyclomatic Complexity
22
Causes of Errors in expressions Boolean operator error Boolean variable error Boolean parenthesis error Relational operator error Arithmetic expression error
Condition testing methods focus on testing each condition in the program.
24
2) Data flow Testing Selects test paths according to the location of definitions and use of variables
Data flow testing identifies paths in the program that go from the assignment of a value to a variable to the use of such variable, to make sure that the variable is properly used. The DU (Definition - Usage) testing strategy requires that each DU chain is covered at least once
25
[1] void k() { [2] x = 11; [3] if (p(cond1)) { [4] y = x + 1; [5] } else if (q(cond2)) { [6] w = x + 3; [7] } else { [8] w = y + 1; [9] } [10]}
We need therefore to derive test cases to match the following conditions: (a) k() is executed and p(cond1) is true (b) k() is executed and p(cond1) is false and q(cond2) is true
26
3) Loop Testing Loops are the fundamental to many algorithms. We Can define loops as simple, concatenated, nested, and unstructured. Cornerstone of every program Loops can lead to non-terminating programs Error in indexes of loops are very easy to occur
Loop Testing is a white-box testing technique that whitefocuses only on the validity of loop constructs
27
Continued
28
32
Issues on black-box testing blackHow is functional validity tested? What classes of input will make good test cases? Is the system particularly sensitive to certain input values? How are the boundaries of a data class isolated? What data rates and data volume can the system tolerate? What effect will specific combinations of data have on system operations?
33
GraphGraph-Based Testing
Complex Systems are hard to understand They can be modeled as interacting objects Test can be performed to ensure that all the required relations are in place
New file menu select
M e nu s e le ct ge ne rate s (ge ne ration time < 1.0 s e c) Docume nt Window
Is re pre s e nte d as
Attributes:
Start dime ns ion:de fault s e tting or pre fe re nce s B ackground color:White Te xt color: de fault color or pre fe re nce s
Docume nt Te xt
34
35
36
output domain
Large number of errors tend to occur at boundaries of the input domain. BVA leads to selection of test cases that exercise boundary values. BVA complements equivalence partitioning. Rather than select any element in an equivalence class, select those at the ''edge' of the class.
38
Examples: 1. For a range of values bounded by a and b, test (a-1), a, (a+1), (b-1), b, (b+1). 2. If input conditions specify a number of values n, test with (n-1), n and (n+1) input values. 3. Apply 1 and 2 to output conditions (e.g., generate table of minimum and maximum size). 4. If internal program data structures have boundaries (e.g., buffer size, table limits), use input data to exercise structures on boundaries
39
Comparison Testing
In some applications the reliability is critical. Redundant hardware and software may be used. For redundant s/w, use separate teams to develop independent versions of the software. Test each version with same test data to ensure all provide identical output. Run all versions in parallel with a real-time comparison of results.
Continued
40
Even if will only run one version in final system, for some critical applications can develop independent versions and use comparison testing or back-to-back testing. When outputs of versions differ, each is investigated to determine if there is a defect. Method does not catch errors in the specification
41
Equivalence Partitioning
42
Divide the input domain into classes of data for which test cases can be generated. Attempting to uncover classes of errors based on equivalence classes for input conditions. An equivalence class represents a set of valid or invalid states An input condition is either a specific numeric value, range of values, a set of related values, or a boolean condition.
Continued
43
Equivalence classes can be defined by: If an input condition specifies a range or a specific value, one valid and two invalid equivalence classes defined. If an input condition specifies a boolean or a member of a set, one valid and one invalid equivalence classes defined. Here we can conclude that in Equivalence partitioning Test cases for each input domain data item developed and executed.
44
Equivalence partitioning
Invalid inputs
Valid inputs
System
Outputs
Example: ATM
Consider data maintained for ATM
User should be able to access the bank using PC and modem (dialing) User should provide six-digit password Need to follow a set of typed commands
Prefix:
three-digit number not beginning with 0 or 1
Suffix:
four digits number
Password:
six digit alphanumeric value
Command:
{check, deposit, bill pay, transfer etc.}
Prefix:
range specific value >200
Suffix:
value (four-digit length)
Password:
Boolean: password may or may not be present value : six char string
Command:
set containing commands noted previously
For example
GCD(45, 27) = 9 GCD (7,13) = 1 GCD(-12, 15) = 3 GCD(13, 0) = 13 GCD(0, 0) undefined
GCD Algorithm
note: Based on Euclids algorithm 1. function gcd (int a, int b) { 2. int temp, value; 3. a := abs(a); 4. b := abs(b); 5. if (a = 0) then 6. value := b; // b is the GCD 7. else if (b = 0) then 8. raise exception; 9. else 10. loop 11. temp := b; 12. b := a mod b; 13. a := temp; 14. until (b = 0) 15. value := a; 16. end if; 17. return value; 18. end gcd
5 7 9 6
1 0 17
18
(1,5,6,17,18), (1,5,7,18), (1,5,7,9,10,17,18), (1,5,7,9,10,9,10,17,18) Equivalence Classes Although the the GCD algorithm should accept any integers as input, one could consider 0, positive integers and negative integers as special values. This yields the following classes: a < 0 and b < 0, a < 0 and b > 0, a > 0 and b < 0 a > 0 and b > 0, a = 0 and b < 0, a = 0 and b > 0 a > 0 and b = 0, a > 0 and b = 0, a = 0 and b = 0 Boundary Values
a = -231, -1, 0, 1, 231-1 and b = -231, -1, 0, 1, 231-1
Anything missing?
What is this?
A failure? An error? A fault? Need to specify the desired behavior first!
Algorithmic Fault
Mechanical Fault
Verification?
Modular Redundancy?
Patching?
Testing?