INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

25
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I

Transcript of INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Page 1: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

INTRUDUCTION TO SOFTWARE TESTING

TECHNIQUES

BY

PRADEEP I

Page 2: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

TESTING THE SOFTWARE

What is it?

Who does it?

When is it done?

How is it done?

Page 3: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

What is software?It is

• Instructions when executed provide desired function and performance

• Data structures that enable the programs to adequately manipulate information and

• Documents that describe the operation and use of the programs

Page 4: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

What is testing?

• Testing is a process of executing a program with the intention of finding an error

• A good test case is one that has a high probability of finding an as-yet-undiscovered error

• A successful test is one that uncovers an as-yet-undiscovered error

Page 5: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Who does it?

• During early stages of testing, software engineer performs all tests.

• As the testing process progresses testing specialists will get involved.

Page 6: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

When is it performed?

• Testing does not start at the end of software process.

• It is performed throughout the software process.

• Test case design and test planning can begin as soon as requirement analysis is completed.

Page 7: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

How is it performed?

It is performed in two perspectives.

1. Internal program logic is exercised using white box testing.

2. Software requirements are exercised using black box testing.

Page 8: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

White box testing

• Guarantees that all independent paths within a module have been exercised at least once.

• Exercises all logical decisions on their true and false sides

• execute all loops at their boundaries and within their operational bounds.

• Exercise internal data structures to ensure their validity.

Page 9: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Basis path testing

1. Using the design or code as foundation, draw a corresponding flow graph.

2. Determine the cyclomatic complexity of the resultant flow graph. The cyclomatic complexity V(G) is provides an upper bound for the number of tests required to ensure that all statements have been executed at least once. It is

V(G) = 6 regions

V(G) = 17 edges - 13 nodes = 6

V(G) = 5 predicate nodes + 1= 6

Page 10: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

3. Determine a basis set of linearly independent paths. The value of V(G) provides the number of linearly independent paths through the program control structure.

Path 1: 1-2-10-11-13

Path 2: 1-2-10-12-13

Path 3: 1-2-3-10-11-13

Path 4: 1-2-3-4-5-8-9-2-….

Path 5: 1-2-3-4-5-6-8-9-2-….

Path 6: 1-2-3-4-5-6-7-8-9-2-….

Page 11: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

4. Prepare test cases that will force execution of each path in the basis set. Data should be chosen so that conditions at the predicate nodes are appropriately set as each path is tested.

Path 1 test case:

value[k] = valid input, where k< i for 2 i 100

value[i] = -999 where 2 i 100

Expected results: correct average based on k values and proper totals.

Note: path 1 can not be tested stand alone. It must be tested as part of path 4,5 and 6.

Page 12: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Path 2 test case:

value[1] = -999

Expected results: average = -999, other totals at initial values.

Path 3 test case:

Attempt to process 101 or more values.

First 100 values should be valid.

Expected results: correct average based on 100 inputs and proper totals.

Page 13: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Path 4 test case:

value[i] = valid input where i < 100

value[k] < minimum where k < I

Expected results: correct average based on k values and proper totals.

Path 5 test case:

value[i] = valid input where i < 100

value[k] > maximum where k < i

Expected results: Correct average based on k values and proper totals.

Page 14: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Path 6 test case:

value[i] = valid input where i < 100

Expected results: Correct average based on given values and proper totals.

5. Each test case is executed and compared to expected results.

Page 15: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

PRECEDURE average; * This procedure computes the average of 100 or fewer numbers that lie between bounding values ; it also computes the sum and the total number valid.

INTERFACE RETURNS average, total.input, total.valid;INTERFACE ACCEPTS value, minimum, maximum;

TYPE value[1:100] IS SCALAR ARRAY;TYPE average, total.input, total.valid, minimum, maximum, sum IS SCALAR;TYPE i IS INTEGER;

Contd...

Page 16: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

i = 1; total.input = total.valid = 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;ENDDOIF total.valid > 0 THEN average = sum / total.valid; ELSE average = -999;ENDIFEND average

1

4

2 3

57

6

89

1011

1213

Page 17: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

1

2

3

4

5

6

8

9

13

12 11

10

7

Flow graph for procedure average

R1

R2

R3R4

R5R6

No. of nodes = 13No. of edges = 17No. of regions = 6No. of predicate nodes = 5

Page 18: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Loop testing

To test simple loops with a maximum of n passes

• Skip the loop entirely.

• Only one pass through the loop.

• Two passes through the loop.

• m passes through the loop where m < n.

• n-1, n, n+1 passes through the loop.

Page 19: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

To test nested loops

• Start at the innermost loop. Set all other loops to minimum values.

• Conduct simple loop tests for the innermost loop.

• Work outward, conducting tests for the next loop.

• Continue until all loops have been tested.

Page 20: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Black box testing

It attempts to find out the errors in the following categories.

• Incorrect or missing functions.

• Interface errors.

• Errors in data structures or external data base access.

• Behavior or performance errors.

• Initialization and termination errors.

Page 21: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Equivalence partitioning

• Divide the input domain into classes of data.

• If input constraints to range, define one valid class and two invalid classes.

• If input constraints to member of a set, define one valid one invalid class.

• If inputs condition is boolean, define one valid and one invalid class.

Page 22: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Boundary value analysis

• If input is a range specified by a and b, test with values a, b, and just below and above a and b.

• Apply above guideline to output conditions.

• If internal program data structures have prescribed boundaries, then exercise the data structure at its boundary.

Page 23: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Testing documentationDocumentation should provide

• Accurate description of how to accomplish each mode of use.

• Accurate description of each interaction sequence.

• Accurate examples.

• Terminology, menu description and system responses that are consistent with actual program.

Page 24: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

• Easy access to locate guidance with in the document.

• Description of troubleshooting.

• Accurate and complete table of contents and index.

• Accurate and complete hyper links.

• Easy navigation for information.

• Good design. (indentation, typefaces, layout, graphics, etc.)

Page 25: INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.

Is this the end?

Testing never ends. It just gets transferred from from us to our customer. Every time the customer uses the program, a test is being conducted.

Our aim of testing is to discover and correct the maximum possible number of errors before the “customer’s tests” begin.