Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill...
-
Upload
baldwin-moore -
Category
Documents
-
view
227 -
download
1
description
Transcript of Testing Overview References: Pressman, Software Engineering: a Practitioners Approach, McGraw Hill...
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
Question
• How do you know your software works correctly?
Question
• How do you know your software works correctly?
• Answer: Try it.
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
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
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
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.
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
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
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?
Example 2
A
B
C
Suppose the loop does not repeat: Only one pass executes
5 distinct paths
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
Example 2
A
B
C
What if it repeats exactly n times?
Example 2
A
B
C
What if it repeats exactly n times?
5n paths
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
Example 3
• Consider testing a Java compiler?• How many inputs are needed to test every
input?
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)
Why Bother?
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.
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!
Levels of Software Testing• Unit/Component testing• Integration testing• System Testing• Acceptance Testing• Installation Testing
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
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
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
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
Levels of Software Testing• Unit/Component testing• Integration testing• System Testing• Acceptance Testing• Installation Testing
– Perform testing with application installed on its target platform
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
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
The problem with testing
• There’s no way to know in general if a test criterion is consistent.
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
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
Competent Programmer Hypothesis
“We assume, as an article of faith, that the programmers are well trained, well supplied with the proper tools, and competent.”
Ad hoc Testing
• Most popular approach• Sometimes called
– “exploratory”– “unstructured”– “random”– “1401 testing”
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.
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.”
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.
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.
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.
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.
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.
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
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