Whats Next INF 117 Project in Software Engineering Lecture Notes - - - PDF document

what s next inf 117 project in software engineering
SMART_READER_LITE
LIVE PREVIEW

Whats Next INF 117 Project in Software Engineering Lecture Notes - - - PDF document

Whats Next INF 117 Project in Software Engineering Lecture Notes - Spring Quarter, 2008 Michele Rousseau Set 8 - Testing Set 8 - Testing 2 Announcements Todays Class k Drop Boxes k Testing We will use drop boxes for the remainder


slide-1
SLIDE 1

1

INF 117 Project in Software Engineering Lecture Notes - Spring Quarter, 2008

Michele Rousseau

Set 8 - Testing

What’s Next

Set 8 - Testing 2

Announcements

k Drop Boxes

  • We will use drop boxes for the remainder of the qtr
  • Please still post all deliverables

◘ EXCEPT: Team Appraisals, Peer Evals & Course Logs

k Due: Thursday

Set 8 - Testing 3

  • Design Iteration #3
  • Code Iteration #1
  • Project Plan #3

k Friday: Cust Approval of Design

Today’s Class k Testing

  • Coverage-Based Testing
  • Equivalence Partitioning

Set 8 - Testing 4

  • Boundary Value Testing

Motivation k People are not perfect

  • We make errors in design and code
  • Goal of testing: given some code,

ibl

Set 8 - Testing 5

uncover as many errors are possible

k Important and expensive activity

  • Not unusual to spend 30-40% of

total project effort on testing

The Purpose of Testing

Design and coding are creative. but… k Testing is Destructive

  • The primary goal is to “break” the software

k Very often the same person does both coding and testing

Set 8 - Testing 6

g g

  • This is not ideal… why?
  • Need “split personality”:

◘when you start testing, become paranoid and malicious

  • Surprisingly hard to do: people don’t like

finding out that they made mistakes

slide-2
SLIDE 2

2

Testing Approach

Testing is a process of executing software with the intent of finding errors k Good testing has a high probability of finding as-yet-undiscovered errors

Set 8 - Testing 7

finding as-yet-undiscovered errors k Successful testing discovers unknown errors k If did not find any errors, need to ask “Was our testing approach is good?”

Testing k Unit Testing k Integration Testing k System Testing

Set 8 - Testing 8

k Regression Testing

V-Model of Development & Testing (the big picture)

Develop Acceptance Tests Acceptance Test Review Requirements Review Develop Requirements Execute System Tests Set 8 - Testing 9 Develop Integration Tests Integration Tests Review Design Review Design Execute Integration Tests Develop Unit Tests Unit Tests Review Code Review Code Execute Unit Tests

Fundamental Testing Questions k Test Criteria: What should we test? k Test Oracle: Is the test correct?

Set 8 - Testing 10

How to make the most of limited resources?

k Test Adequacy: How much is enough? k Test Process: Is our testing effective?

Some Commonly Used Testing Approaches

k Coverage or Control-flow based k Data-flow based k Equivalence Partitioning

Set 8 - Testing 11

k Equivalence Partitioning k Boundary Value Analysis Coverage-Based Testing k Flow Graphs

  • Control Flow

◘Partial order of Statement Execution

k D Fl

Set 8 - Testing 12

k Data Flow

◘Flow of values from Definition to Variables

Graph representation of control flow and data flow relationships

slide-3
SLIDE 3

3

2,3,4 5 6 9´ 10 14 T T F F 9 T F 7 T F 9a 9b

Prog P’s Control Flow Graph (CFG)

Set 8 - Testing 13

12 F

function P return INTEGER is begin X, Y: INTEGER; READ(X); READ(Y); while (X > 10) loop X := X – 10; exit when X = 10; end loop; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 if (Y < 20 and then X mod 2 = 0) then Y := Y + 20; else Y := Y – 20; end if; return 2*X + Y; end P; 1 2 3 4 5 6 7 8

All-Statements Coverage k Select test cases such that every node in the graph is visited

  • Also called node coverage

◘G ara tees that e er state e t i

Set 8 - Testing 14

◘Guarantees that every statement in the source code is executed at least

  • nce

k Selects minimal number of test cases

6 10 T F T 7 T F At least 2 test cases needed

All-Statements Coverage of P

Set 8 - Testing 15

2,3,4 5 12 14 F 9 F Example all-statements-adequate test set: (X = 20, Y = 10) < 2,3,4,5,6,7,9,10,14> (X = 20, Y = 30) < 2,3,4,5,6,7,9,12,14>

All-Branches Coverage k Select test cases such that every branch in the graph is visited

◘Guarantees that every branch in the source code is executed at least once

Set 8 - Testing 16

source code is executed at least once

k More thorough than All- Statements coverage

  • More likely to reveal logical errors

2,3,4 5 6 10 14 T F 9 T 7 T F At least 2 test cases needed

All-Branches Coverage of P

Set 8 - Testing 17

2,3,4 5 12 14 9 F Example all-branches-adequate test set: (X = 20, Y = 10) < 2,3,4,5,6,7,9,10,14> (X = 15, Y = 30) < 2,3,4,5,6,7,5,9,12,14>

All-Edges Coverage k Select test cases such that every edge in the graph is visited

◘Takes complex statements into consideration – treats them as

Set 8 - Testing 18

consideration treats them as separate nodes

k More thorough than All-Branches coverage

  • More likely to reveal logical errors
slide-4
SLIDE 4

4

2,3,4 5 6 9b 10 14 T T F 9a T 7 T F At least 3 test cases needed

All-Edges Coverage of P

Set 8 - Testing 19

12 F F Example all-edges-adequate test set: (X = 20, Y = 10) < 2,3,4,5,6,7,9a,9b,10,14> (X = 5, Y = 30) < 2,3,4,5,9a,12,14> (X = 21, Y = 10) < 2,3,4,5,6,7,5,6,7,5,9a,9b,12,14>

All-Paths Coverage k Path coverage

  • Select test cases such that every

path in the graph is visited

  • L

bl

Set 8 - Testing 20

  • Loops are a problem

◘0, 1, average, max iterations

k Most thorough… …but is it feasible?

2 3 4 5 6 9b 10 14 T T F 9 T 7 T F Infinitely many test cases needed

All-Paths Coverage of P

Set 8 - Testing 21

2,3,4 5 9b 12 14 F 9a F Example all-paths- adequate test set: (X = 5, Y = 10) (X = 15, Y = 10) (X = 25, Y = 10) (X = 35, Y = 10) …

Subsumption of Criteria k C1 subsumes C2 if any C1- adequate test T is also C2- adequate

  • B t

T1 ti f i C1

Set 8 - Testing 22

  • But some T1 satisfying C1 may

detect fewer faults than some T2 satisfying C2

Data-flow

Test connections between variable definitions (“write”) and variable uses (“read”) k Variation of the control flow graph

  • A ode represe ts a si gle state e t ot a

Set 8 - Testing 23

  • A node represents a single statement, not a

single-entry-single-exit chain of statements

k Set DEF(n) DEF(n) contains variables that are defined at node n (i.e., they are written) k Set USE(n USE(n): : variables that are read

Def-Use Pair

k A def-use (DU) pair for variable x x is a k pair of nodes (n1,n (n1,n2) ) such that

  • x

x is in DEF(n1) DEF(n1)

  • the definition of x

x at n1 n1 reaches n2 n2 USE( USE( 2) 2)

Set 8 - Testing 24

  • x is in USE(

USE(n2) 2)

k i.e., the value that is assigned to x x at n1 n1 is used at n2 n2

  • Since the definition reaches n2

n2, the value is not “killed” along some path n1… n1…n2

slide-5
SLIDE 5

5

6 10 T

X Y Y X X X

T 7 T F

X X

P’s Control and Data Flow Graph

Set 8 - Testing 25

2,3,4 5 9b 12 14 T F 9a T F

Y X Y X X Y

T F

Test Adequacy

k Coverage-Based Testing

  • Coverage metrics

◘ when sufficient percentage of the program structure has been exercised

k Fault-Based Testing

  • E

i i l Tells you when to stop testing

Set 8 - Testing 26

  • Empirical assurance

◘ when failures/test curve flatten out

  • Error seeding

◘ percentage of seeded faults found is proportional to the percentage

  • f real faults found

k Error-Based Testing

  • faults found in common are representative of total

population of faults

  • Equivalence Partitioning

Test Criteria

k Testing must select a subset of test cases that are likely to reveal failures k Test Criteria provide the guidelines, rules, strategy by which test cases are selected

  • actual test data
  • conditions on test data
  • requirements on test data

Set 8 - Testing 27

  • requirements on test data

k Equivalence partitioning is the typical approach

  • a test of any value in a given class is equivalent to a

test of any other value in that class

  • if a test case in a class reveals a failure, then any other

test case in that class should reveal the failure

  • some approaches limit conclusions to some chosen

class of errors and/or failures

Equivalence Partitioning (EQP) k Testing technique Testing technique

  • Reduces the # of test cases

◘Make the # of test cases manageable S t ti d i ti f t t

Set 8 - Testing 28

◘Systematic derivation of test cases

  • Reasonably tests the system

Basic Principle: Some distinctions don’t make a difference

EQP : How does it work Divid Divide inputs into inputs into equivalent partitions partitions

  • ie Find a small # set of

Basic Method: Notice when any element in the partition will produce the same results (ie find the same faults)

Set 8 - Testing 29

  • i.e. Find a small # set of

re representative entativeinput values

  • For each Class program behaves in

an “equivalent” way

  • Smaller test set – but equally

effective

EQP: Reduces test cases

Input domain

2

Input domain partitioned into four sub-domains.

Set 8 - Testing 30

1 2 3 4

Large set of test inputs. Four test inputs, one selected from each sub-domain.

slide-6
SLIDE 6

6

How to partition? Example 1 k Suppose that program P takes an input X, X being an integer.

Set 8 - Testing 31

k For X<0 perform task (T1) k For X>=0 perform task (T2)

Set 8 - Testing 32 Set 8 - Testing 33

Two sub-domains

One Possible Test Case: X=-3 Another test case: X=15 X<0 X>=0 Equivalence class Equivalence class

Set 8 - Testing 34 All test inputs in the X<0 sub-domain are considered

equivalent.

The assumption is that if one test input in this sub-domain

reveals an error in the program, so will the others.

This is true of the test inputs in the X>=0 sub-domain also.

EQP: Basic Process

k First you must break the input into sub-domains (partitions)

  • Look at input and determine common properties
  • Values with in defined range
  • Values outside of the defined range
  • Extremes

Set 8 - Testing 35

Extremes

  • Try to include input that will force incorrect output

◘ How well does the code perform exception handling

k If the sub-domains are well done

  • should be able to create a few (or ideally) one test

case that will represent the entire domain

Include inputs in and out of range

Ie Input Test Data

Inputs causing anomalous behavior

Set 8 - Testing 36

Oe

Output Set

Outputs which reveal the presence of defects

System

slide-7
SLIDE 7

7

EQP: Example 2

k Input should be a numerical month

  • Valid Inputs: 1-12

k What are potential Classes?

  • Input within range:

Set 8 - Testing 37

p g

◘1-12

  • Out of Range

◘High End: 20, 99, 3-digit, 4-digit ◘Low End: Negative Numbers ◘Alphanumeric ◘Special Characters / Punctuation

Boundary Value Analysis (BVA)

k Select test cases based on the boundaries values k Look for inputs

  • On the boundary
  • On either side of the boundary

k F i th l

Set 8 - Testing 38

k For numeric month example

  • Boundary Values

◘ Low End: 0,1,2 ◘ High End: 11,12,13

k Combining this technique with Equivalence Partitioning is much more effective

EQP &BVA

k Input

  • 5-digit integer between 10,000 and 99,999,

k Partitions

  • <10,000
  • 10,000-99,999
  • > 10, 000

k B d V l

Set 8 - Testing 39

k Boundary Values

  • 00000
  • 09,999 –10,000
  • 99,998 – 99,999 – 100,000

k Outside

  • Alphanumeric
  • Symbols

What do you need to do? k Have a plan!

  • Not monkey testing

k Create test cases wisely (think b h h )

Set 8 - Testing 40

about what they are covering) k Define your test cases and results k See Read-set templates Ready-set Templates k http://readyset.tigris.org/nonav /templates/frameset.html k http://readyset.tigris.org/nonav /t l t /f tht l

Set 8 - Testing 41

/templates/frameset.html k Add results.. Pass/fail Integration Testing

k Purpose: to exercise the interfaces between classes/modules

  • Driven by design
  • What should it take in?
  • What should it supply?

Set 8 - Testing 42

  • What should it supply?
  • What happens if they send the wrong

stuff?

k Basic approaches

  • Top-Down
  • Bottom-up

Run tests developed during the design phase

slide-8
SLIDE 8

8

Which Approach to use? k Top-Down or Bottom Up? k In practice, most integration involves a combination of these t t

Set 8 - Testing 43

strategies System Testing k Black box… k Running Acceptance Test Plan

Set 8 - Testing 44

One Last Announcement

k No class Wednesday

Set 8 - Testing 45