42
Testing Overview References: Pressman, Software Engineering: a Practitioner’s Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice, Prentice Hall J. McGregor and D. Sykes. A Practical Guide to Testing Object-Oriented Software, Addison-Wesley, 2001. I. Burnstein. Practical Software Testing, Springer- Verlag, 2003. 1209

Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Embed Size (px)

DESCRIPTION

Question How do you know your software works correctly? Answer: Try it.

Citation preview

Page 1: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Testing Overview

References:Pressman, Software Engineering: a Practitioner’s Approach, McGraw HillPfleeger, Software Engineering, Theory and Practice, Prentice HallJ. McGregor and D. Sykes. A Practical Guide to Testing Object-Oriented Software, Addison-Wesley, 2001.I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.

1209

Page 2: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Question

• How do you know your software works correctly?

Page 3: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Question

• How do you know your software works correctly?

• Answer: Try it.

Page 4: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Question

• How do you know your software works correctly?

• Answer: Try it.• Example: I have a function of one integer

input. I try f(6). It returns 35. – Is my program correct?

Groups of 31 minute

Page 5: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Question

• How do you know your software works correctly?

• Answer: Try it.• Example: I have a function of one integer

input. I try f(6). It returns 35. – My function is supposed to compute n*6-1. Is it

correct? – Is my program correct? Groups of 3

1 minute

Page 6: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Goals of testing:

I want to show that my program is correct: it generates the right answer for every input.

Can we write tests to show this?

Groups of 31 minute

Page 7: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Goals of testing:

Can we prove a program is correct by testing?Yes, if we can test it exhaustively: every

combination of inputs in every environment.

    

Page 8: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

How long will it take?

• Consider X+Y for 32-bit integers.• How many test cases are required?

• How long will it take?– 1 test per second:– 1,000 tests per second:– 1,000,000 per second:

Groups of 3

Page 9: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

How Long?

• Consider X+Y for 32-bit integers.• How many test cases are required?

232 * 232 = 264 =1019

(The universe is 4*10^17 seconds old)• How long will it take?

1 test per second: 580,000,000,000 years1,000 tests per second: 580,000,000 years1,000,000 per second: 580,000 years

Page 10: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

A loop returns to A

We want to count the number of paths

The maximum number of iterations of the loop is 20

How many?

Page 11: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

Suppose the loop does not repeat: Only one pass executes

5 distinct paths

Page 12: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

Suppose the loop repeats exactly once

5*5=25 distinct paths

If it repeats at most once,

5 + 5*5

Page 13: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

What if it repeats exactly n times?

Page 14: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

What if it repeats exactly n times?

5n paths

Page 15: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 2

A

B

C

What if it repeats at most n times?

∑5n = 5n + 5n-1+ … + 5

N=20, ∑5n = 1015

32 years at 1,000,000 tests per second

Page 16: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Example 3

• Consider testing a Java compiler?• How many inputs are needed to test every

input?

Page 17: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Limits of testing:

• You can’t test it completely. • You can’t test all valid inputs. • You can’t test all invalid inputs.• You really can’t test edited inputs.• You can’t test in every environment.• You can’t test all variations on timing.• You can’t even test every path. (path, set of lines

executed, start to finish)

Page 18: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Why Bother?

Page 19: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Goals of testing:

• Identify errors.– Make errors repeatable (when do they occur)– Localize errors (where are they)

• The purpose of testing is to find problems in programs so they can be fixed.

Page 20: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Cost• Testing accounts for between 30 and 90% of the

total cost of software• Microsoft employs one tester for each developer• We want to reduce the cost

– Increase test efficiency: #defects found/test – Reduce the number of tests– Find more defects

• How?• Organize!

Page 21: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing• Integration testing• System Testing• Acceptance Testing• Installation Testing

Page 22: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing

– Verify implementation of each software element

– Trace each test to detailed design• Integration testing• System Testing• Acceptance Testing• Installation Testing

Page 23: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing• Integration testing

– Combine software units and test until the entire system has been integrated

– Trace each test to high-level design• System Testing• Acceptance Testing• Installation Testing

Page 24: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing• Integration testing• System Testing

– Test integration of hardware and software– Ensure software as a complete entity complies with

operational requirements– Trace test to system requirements

• Acceptance Testing• Installation Testing

Page 25: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing• Integration testing• System Testing• Acceptance Testing

– Determine if test results satisfy acceptance criteria of project stakeholder

– Trace each test to stakeholder requirements• Installation Testing

Page 26: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Levels of Software Testing• Unit/Component testing• Integration testing• System Testing• Acceptance Testing• Installation Testing

– Perform testing with application installed on its target platform

Page 27: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Testing Phases: V-Model RequirementsSpecification

SystemSpecification

SystemDesign

Detailed Design

Unit code andTest

Sub-systemIntegration test

System Integration test

AcceptanceTestService

AcceptanceTest Plan

System IntegrationTest Plan

Sub-systemIntegrationTest Plan

Page 28: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Hierarchy of TestingTesting

Program Testing

Top Down

Bottom Up

Integration TestingUnit Testing

System Testing

Big Bang

Sandwich

Black Box

White Box

Function

Performance

Reliability

Availability

AcceptanceTesting

Properties

Security

Equivalence

Boundary

Decision Table

State Transition

Use Case

Domain Analysis

Control Flow Data Flow

Usability

Documentation

Portability

Capacity

Ad hoc

Benchmark

Pilot

Alpha

Beta

Page 29: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

The problem with testing

• There’s no way to know in general if a test criterion is consistent.

Page 30: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Who Tests?

• Professional testers: Organize and run tests• Analysts: involved in system requirements

definition and specification• System designers: understand proposed solution and

solution’s constraints• Implementers: Understand constraints associated

with implementation• Configuration management representative:

arranges for changes to be made consistently across all artifacts

Page 31: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

A good test:

• Has a reasonable probability of catching an error

• Is not redundant• Is neither too simple nor complex• Reveals a problem• Is a failure if it doesn’t reveal a problem

Page 32: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Competent Programmer Hypothesis

“We assume, as an article of faith, that the programmers are well trained, well supplied with the proper tools, and competent.”

Page 33: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Ad hoc Testing

• Most popular approach• Sometimes called

– “exploratory”– “unstructured”– “random”– “1401 testing”

Page 34: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Ad hoc Testing

• Most popular approach• Sometimes called

– “exploratory”– “unstructured”– “random”– “1401 testing”

Random testing is actually different: ad hoc is rarely

random.

It is likely that there is some structure, but the structure is

informal and based on experience, thus difficult to

describe.

Page 35: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Ad Hoc TestingSimple example (Kaner):

“The program is designed to add two numbers, which you enter. Each number should be one or two digits. The program will echo your entries, then print the sum. Press <Enter> after each number. To start the program, type ADDER.”

Page 36: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Simple example 2:

Step 1. start with simple, obvious test. Type ADDER, 2, 3 and see what happens.

There might be lots of things to note. Do things line up? Is there adequate advice?

Step 2. Make notes about what else can be tested. After the obvious ones, start constructing a formal test series.

Page 37: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Simple example 3:Step 3. Look for boundary conditions: Cases: 99 + 99, -99 + -99, 99 + -14, -38 + 99,56 + 99, 9+9, 0+0, 0+23, -78 + 0

Use each digit at least once.Test things likely to fail (boundaries)

largest single digit, large second number, large first number

if it passes 2+3, you expect it to pass 3+4. In some sense, they are the same.

Page 38: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Simple example 4:Step 4. Do some “on the fly” testing. Run

with whatever feels right. Keep track of these tests.How about the invalid side of boundaries: 100+100, <> + <>, 1.2 + 5, control keys, etc.

Step 5. summarize what you know about it. This is for your own use. Write a problem report for each bug.

Page 39: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Simple example 5:

Step 6. Think of hidden boundaries. What about single byte signed numbers: -127-+127. Look at sums greater than 127 (which we already did, but look for strange results here.)

Testing for valid or invalid characters: test “0”(48), “/”(47), “9”(57), “:”(58) and so on.

 Next cycle, review responses to problem reports and

see what’s been done.

Page 40: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Automate testing

• Do whenever possible. Design it for this.• “A century ago the steam locomotive

reached it’s peak. Fifty years before that intercity stagecoaches pulled by teams of horses had an outrider on the first horse to stabilize the team. Manual testing to me is like having such a rider at the front of a speeding locomotive.” Beizer.

Page 41: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Advice

• View testing as part of the development process

• Buy a tool and use it• Testing is the last line of defense: Errors

indicate there is a problem with the development process

Page 42: Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill Pfleeger, Software Engineering, Theory and Practice,

Closing words

• “Testing is our last line of defense against bugs, not the first or only line of defense. When a bug is found by testing, it means that earlier phases of our software development process are wanting.”

• “I don’t see testing actually disappearing because the remaining bugs are always subtler and nastier.”

– Bezier