28
Unit IV 1

Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

Embed Size (px)

Citation preview

Page 1: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

Unit IV

1

Page 2: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 2

Testing

“How to find bugs in the software?”

Testing is the process of exercising aTesting is the process of exercising a

program with the specific intent of findingprogram with the specific intent of finding

errors prior to delivery to the end user.errors prior to delivery to the end user.

Page 3: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 4

Validation & VerificationTesting is part of V&VValidation

“Are we building the product right?” Ensure software meets customer’s needs.

Verification “Are we building the right product?” Ensure software meet specification.

Page 4: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 6

Testing Objectives

Software Testing is a process of executing a program with the intent 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: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 10

Testing Principles

All test should be traceable to customer requirements.

Tests should be planned before testing begins.

Page 6: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

Charecteristics of testable software

Operability.ObservabilityControllabilityDecomposabilitySimplicityStabilityUnderstandability

TCS2411 Software Engineering 11

Page 7: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

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 be neither too

simple nor too complex.

TCS2411 Software Engineering 12

Page 8: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 17

Test Cases

Test case : unit of testing activityTest cases have 3 parts :-

Goal Aspect of the system being tested

Input and system stateData provided to the system under stated condition

Expected behaviorThe output or action the system should take

according to its requirements

Page 9: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 18

Test Cases (Cont)

Test cases are derived during all phase of development cycle

Determine the expected result before running the test case

Record test cases and its resultsAllocate

money people resourcestime

Page 10: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 19

Type Of Test Cases

Test cases are derived for Valid and expected input Invalid and unexpected input Test if the system does less than

specified requirement Test if the system does more than

specified requirement

Page 11: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 20

White Box Testing

Derived from knowledge of program’s structure & implementation

Structural testing - analyse code & use knowledge of the structure of a component to derive test data

Logical paths are tested by providing test cases that exercise specific sets of conditions and/or loops

Page 12: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 21

White Box Testing (Continued)

Thorough white box testing would lead to “100 percent correct programs”

Exhaustive testing are impractical - too many tests!

A limited number of logical paths can be selected and exercised

Important data structures can be probed for validity

Page 13: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 22

White Box Test Cases

Guarantee that all independent paths have been exercised at least once

Exercise 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 14: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 23

White Box Testing Techniques

Basis path testing Flow graph notation Cyclomatic complexity Derived test cases Graph metrics

Control structure testing Condition testing Data Flow testing Loop testing

Page 15: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 24

Flow Graph Notation

1

2

3

6

7 8

4

5

9

1011

1

2,3

6

7 8

9

10

11

4,5

NodeEdge

R3

R2

R1

R4

Region

Page 16: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 25

Cyclomatic Complexity

Provide quantitative measure for program logical complexity.

Defined number of independent path Any path that introduce one set of processing

statements or new conditionEg :-

Path 1 : 1-11 Path 2 : 1-2-3-4-5-10-1-11 Path 3 : 1-2-3-6-8-9-10-1-11 Path 4 : 1-2-3-6-7-9-10-1-11

Page 17: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 26

How Is Cyclomatic Complexity Computed?( Refer 24 slide )

1. Number of regions The flow graph has 4 regions

2. V(G) = E – N + 2 E : Number of flow graph edges N : Number of flow graph nodes

V(G) = 11 edges – 9 nodes + 2 = 4

3. V(G) = P + 1 P : Number of predicate nodes

V(G) = 3 predicate nodes + 1 = 4

Page 18: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 27

Deriving Test Cases1. Draw flow graph from design/code as foundation.

…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 end if increment i by 1End doIf total.valid > 0 then average = sum / total valid; else average = -999;End if…

1

2

3

4

56

7

8

910

11

12

13

1

2

3

4

5

6

78

9

10

1112

13

Page 19: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 28

Deriving Test Cases (cont)

2. Determine cyclomatic complexity V(G) = 6 regions V(G) = 17 edges – 13 nodes + 2 = 6 V(G) = 5 predicates nodes + 1 = 6

3. Determine a basis set of linearly independent graph

Path 1 = 1-2-10-11-13 Path 2 = 1-2-10-12-13 ….

4. Prepare test cases Path 1 test case :

value(k) = valid input where k < i defined below value(i) = -999 where 2 <= i <= 100 Expected result : Correct average based on k value and

proper totals

Page 20: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 29

Discussion on White Box Testing

Advantages Find errors on code level Typically based on a very systematic

approach, covering the complete internal module structure

Constraints Does not find missing or additional

functionality Does not really check the interface Difficult for large and complex module

Page 21: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 30

Black Box Testing

Derived from program specificationFunctional testing of a component of

a systemExamine behaviour through inputs &

the corresponding outputsInput is properly accepted, output is

correctly producedDisregard internal logical structure

Page 22: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 31

Black Box Testing (Continued)

Attempts to find the following errors:Incorrect or missing functionsInterface errorsErrors in data structures or external

database accessPerformance errorsInitialisation and termination errors

Page 23: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 32

Black Box Testing Techniques

Graph Based Testing MethodsEquivalence PartitioningBoundary Value AnalysisComparison TestingOrthogonal Array Testing

Page 24: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 33

Equivalence Partitioning

Divide input domain into classes of dataBased on an evaluation of equivalence classes

for an input conditionGuidelines to define equivalence classes

Range input : One valid and two invalid equivalence Specific value : One valid and two invalid

equivalence A member of a set : One valid and one invalid

equivalence Boolean : One valid and one invalid equivalence

Page 25: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 34

Example – Data for Automated Banking Application

The use can access the bank using his personal computer, provide a six digit password, and follow with a series of typed commands that trigger various banking function. During the log on sequence the software supplied for the banking application accepts data in the form:

area code – blank or 3 digit numbersprefix – 3 digit numbers, nor beginning with 0 or 1suffix – 4 digit numberspassword – 6 digits alphanumeric stringscommands – “check”, “deposit”, “bill pay” etc

Input condition

area code : Input condition : Boolean – area code may or may not present Input condition : Range – 200 – 999 with specific exception

prefix : Input condition : Range – specified value > 200 with no 0 digitssuffix : Input condition : Value – 4 digit lengthpassword : Input condition : Boolean – password may or may not present

Input condition : Value – six character stringcommand : Input condition : Set – containing command

Page 26: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 35

Boundary Value Analysis

Complement equivalence partitioningTest both sides of each boundary Look at output boundaries for test

cases Test min, min-1, max, max+1, typical

valuesExample : 1 <= x <=100

Valid : 1, 2, 99, 100 Invalid : 0 and 101

Page 27: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 36

Discussion on Black Box Testing

Advantages Find missing functionality Independent from code size and

functionality Find some coding errors

Constraints No systematic search for low level errors Specification errors not found

Page 28: Unit IV 1 TCS2411 Software Engineering2 Testing “How to find bugs in the software?” zTesting is the process of exercising a program with the specific

TCS2411 Software Engineering 37

References

“Software Engineering: A Practitioner’s Approach” 5th Ed. by Roger S. Pressman, Mc-Graw-Hill, 2001

“Software Engineering” by Ian Sommerville, Addison-Wesley, 2001