+ All Categories
Home > Documents > M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified...

M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified...

Date post: 21-Aug-2018
Category:
Upload: dangbao
View: 213 times
Download: 0 times
Share this document with a friend
52
TESTING STRATEGIES M. Weintraub and F. Tip Thanks go to Andreas Zeller for allowing incorporation of his materials
Transcript
Page 1: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

TESTING STRATEGIES

M. Weintraub and

F. Tip

Thanks go to Andreas Zeller for allowing

incorporation of his materials

Page 2: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

TESTING

Testing: a procedure intended to establish the quality, performance, or

reliability of something, esp. before it is taken into widespread use

2

Page 3: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

RECALL FROM BEFORE – THESE ARE OUR

TECHNIQUES FOR EVALUATING SOFTWARE

33

Testing(dynamic verification)

Inspections(static verification)

Program

Analysis(static or dynamic)

Proofs(static verification)

Page 4: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

THE CURSE OF FUNCTIONAL TESTING

∞ possible runs

a t

est ru

n

a t

est ru

n

a t

est ru

n

a t

est ru

n

optimistic

inaccuracy

Dijkstra’ Curse: Testing can

show the presence

but not the absence of errors

4

Page 5: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

ITS STRUCTURAL TESTING COROLLARY

5

a proof

ab

str

actio

n

∞ possible runs

non-simplified

properties

Zeller’s Corollary: Static Analysis

can confirm the absence but not

the presence of errors

Page 6: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

COMBINING METHODS

∞ possible runs

a t

est ru

n

a t

est ru

n

a t

est ru

n

a t

est ru

n

ab

str

actio

n

a proof

a proof

unverified

properties

6

Page 7: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

WHY IS SOFTWARE VERIFICATION

HARD?Many different quality requirements

Evolving (and deteriorating) structure

Inherent non-linearity

Uneven distribution of faults

7

Page 8: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

WHY IS SOFTWARE VERIFICATION

HARD?Many different quality requirements

Evolving (and deteriorating) structure

Inherent non-linearity

Uneven distribution of faults

8

If an elevator can safely carry a load of

1000 kg, it can also safely carry any smaller

load

Page 9: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

WHY IS SOFTWARE VERIFICATION

HARD?Many different quality requirements

Evolving (and deteriorating) structure

Inherent non-linearity

Uneven distribution of faults

9

If a procedure correctly sorts a set of 256

elements, it may fail on a set of 255 or 53

elements, as well as on 257 or 1023

If an elevator can safely carry a load of

1000 kg, it can also safely carry any smaller

load

Page 10: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

A TESTING PROGRAM INVOLVES TRADE-

OFFS

We can be inaccurate

(optimistic or pessimistic)

or we can simplify

properties…

but you cannot have it all!

10

Page 11: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Waterfall Model(1968)

Communicatio

nproject initiation

requirements gatheringPlanningestimating

scheduling

tracking

Modelinganalysis

design

Constructioncode

test

Deploymentdelivery

support

feedback

Page 12: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Waterfall Model(1968)

Communicatio

nproject initiation

requirements gatheringPlanningestimating

scheduling

tracking

Modelinganalysis

design

Constructioncode

test

Deploymentdelivery

support

feedback

Page 13: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

We built it!

Page 14: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Shall we deploy it?

Page 15: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Waterfall Model(1968)

Constructioncode

test

Page 16: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Waterfall Model(1968)

Constructioncode

test

Deploymentdelivery

support

feedback

Page 17: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

V & V

Validation

Ensuring that software has been

built according to customer

requirements

Verification

Ensuring that software correctly implements a specific function

Are we building the

right product or

service?

Are we building the

product or service

right?

17

Page 18: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

VALIDATION AND VERIFICATION

Actual

Requirements

SW

SpecsSystem

Validation Verification

Involves usability testing, user

feedback, & product trials

Includes testing, code

inspections, static analysis, proofs

18

Page 19: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

VALIDATION

“if a user presses a request button at floor i, an available

elevator must arrive at floor i soon”

not verifiable, but validatable

19

Page 20: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

VERIFICATION

“if a user presses a request button at floor i, an available

elevator must arrive at floor i within 30 seconds”

verifiable

20

Page 21: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

CORE QUESTIONS

When does V&V start? When is it done?

Which techniques should be applied?

How do we know a product is ready?

How can we control the quality of successive releases?

How can we improve development?

21

Page 22: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

Waterfall Model(1968)

Code

Test

Page 23: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

FIRST CODE, THEN TEST

1. Developers on software should do no testing at all

2. Software should be “tossed over a wall” to strangers who

will test it mercilessly

3. Testers should get involved with the project only when

testing is about to begin

23

Page 24: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

V MODEL

Module Test

Page 25: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

UNIT TESTS

Aims to uncover errors at module boundaries

Typically written by programmer herself

Should be completely automatic (→ regression testing)

25

Page 26: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

TESTING COMPONENTS: STUBS AND DRIVERS

A driver exercises a

module’s functions

A stub simulates not-

yet-ready modules

Frequently realized as

mock objects

Driver

Stub Stub

26

Page 27: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

PUTTING THE PIECES TOGETHER:

INTEGRATION TESTS

General idea: Constructing software while conducting tests

Options: Big Bang or Incremental Construction

27

Page 28: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

BIG BANG APPROACH

All components are combined

in advance

The entire program is tested

as a whole

28

Page 29: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

BIG BANG APPROACH

All components are combined

in advance

The entire program is tested

as a whole

29

Chaos results!

For every failure, the entire program must be taken into

account

Page 30: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

TOP-DOWN INTEGRATION

Top module is tested

with stubs (and then used

as driver)

Stubs are replaced

one at a time (“depth

first”)

As new modules are

integrated, tests are

re-run

Allows for early demonstration of capability30

Stub Stub Stub

A

Stub

StubD

Stub

Stub

C

B

Page 31: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

BOTTOM-UP INTEGRATION

Bottom modules implemented first and combined into clusters

Drivers are replaced one at a time

Removes the need for complex stubs

CDriver

D E

Driver

F

Allows for early demonstration of capability

31

Page 32: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

SANDWICH INTEGRATION

Combines bottom-up and

top-down integration

Top modules tested with

stubs, bottom modules

with driversC

D E

Drive

r

F

A

Stub StubStubB

Combines the best of the two approaches

32

Page 33: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

ONE DIFFERENCE FROM UNIT TESTING:

EMERGENT BEHAVIOR

Some behaviors are only

clear when components are

put together

Usually this is identified

after the fact,

and causes test

suites/cases to be

refactored.

Page 34: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

WHO TESTS THE SOFTWARE?

Independent Tester

must learn about system

will attempt to break it

driven by quality

Developer

understands the system

but will test gently

driven by delivery 34

Page 35: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

WEINBERG’S LAW

A developer is unsuited

to test his or her code.

35

Page 36: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

EVERYONE IS A TESTER!

Experienced Outsiders and Clients

Good for finding gaps missed by developers, especially domain specific items

Inexperienced Users

Good for illuminating other, perhaps unintended uses/errors

Mother Nature

Crashes tend to happen during an important client/customer demo…

36

Page 37: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

SYSTEM TESTING

37

Page 38: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

SPECIAL KINDS OF SYSTEM TESTING

Recovery testing

forces the software to fail in a variety of ways and verifies that recovery is properly

performed

Security testing

verifies that protection mechanisms built into a system will, in fact, protect it from

improper penetration

Stress testing

executes a system in a manner that demands resources in abnormal quantity,

frequency, or volume

Performance testing

test the run-time performance of software within the context of an integrated system

38

Page 39: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

PERFORMANCE TESTING

Measures a system’s capacity to

process a specific load over a

specific time-span, usually:

1. number of concurrent users

2. specific number of

concurrent transactions

Involves defining and running

operational profiles that

reflect expected use

39

Page 40: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

TYPES OF PERFORMANCE TESTING

1. Load

Aims to assess compliance with non-functional requirements

2. Stress

Identifies system capacity limits

3. Spike

Testing involving rapid swings in load

4. Endurance (or Soak)

Continuous operation at a given load

40

Page 41: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

MANY OPTIMIZATIONS ARE POSSIBLE

For Throughput or Concurrency?

Getting the most data processed

Greatest number of simultaneous transactions

For Server response time?

For Service request round-trip time?

For Server utilization?

For End-User Experience?

For Cost?

Page 42: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

SECURITY TESTING

Confidentiality

Information protection from unauthorized access or disclosure

Integrity

Information protection from unauthorized modification or

destruction

Availability

System protection from unauthorized disruption42

Page 43: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

ACCEPTANCE TESTING

43

Page 44: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

ACCEPTANCE TESTING

Acceptance testing checks whether contractual requirements are met

May be incremental

Alpha / Beta

Work is over when acceptance testing is done

44

Page 45: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

HOW DO WE KNOW WHEN A PRODUCT IS READY?

Let the customer test it :-)

We’re out of time…

Relative to a theoretically sound and experimentally validated statistical

model, we have done sufficient testing to say with 95% confidence that

the probability of 1,000 CPU hours of failure-free operation is ≥ 0.995.

45

Page 46: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

REGRESSION TESTS

set up automated tests

using, e.g., JUnit

ideally, run regression tests after

each change

if running the tests takes too long:

prioritize and run a subset

apply regression test

selection to determine tests

that are impacted by a set of

changes

46

Page 47: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

COLLECTING DATA

47

Page 48: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

REMEMBER PARETO’S LAW

48

Approximately 80% of defects

come from 20% of modules

Page 49: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

CORE QUESTIONS

When does V&V start? When is it done?

Which techniques should be applied?

How do we know a product is ready?

How can we control the quality of successive releases?

How can we improve development?

49

Page 50: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

BEST PRACTICES

Specify requirements in a quantifiable manner

State testing objectives explicitly

Understand the users of the software and develop a profile

for each user category

Develop a testing plan that emphasizes “rapid cycle testing”

50

Page 51: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

BEST PRACTICES

Build “robust” software that is designed to test itself

Use effective formal technical reviews as a filter prior to

testing

Conduct formal technical reviews to assess the test strategy

and test cases themselves

Develop a continuous improvement approach for the testing

process

51

Page 52: M. Weintraub and F. Tip - Northeastern University · M. Weintraub and F. Tip ... non-simplified properties Zeller’s Corollary: Static Analysis can confirm the absence but not ...

DESIGN FOR TESTING

OO design principles also improve testing

Encapsulation leads to good unit tests

Provide diagnostic methods

Primarily used for debugging, but may also be useful as

regular methods

Assertions are great helpers for testing

Test cases may be derived automatically

52


Recommended