Software Testing Lect 2-3
Software Testing Lect 2-3
Software Testing Lect 2-3
Basics of Testing
Testing & Debugging Activities
Testing Strategies
Black-Box Testing
White-Box Testing
Unit Test
Integration Test
System Test
Acceptance Test
Regression Test
Practical Considerations
1
Requirements
specification
Architecture
Detailed
design
Implementation
V1
Implementation
V2
Prototype
Dynamic
V &V
Special cases
Executable specifications
Acceptance
test
Customer
Developer
System test
Integration test
Unit test
Functional
(BB)
Structural
(WB)
3
Testing stages
Unit testing
Testing of individual components
Integration testing
Testing to expose problems arising from the
combination of components
System testing
Testing the complete system prior to delivery
Acceptance testing
Testing by users to check that the system satisfies
requirements. Sometimes called alpha testing
4
Types of testing
Statistical testing
Tests designed to reflect the frequency of user
inputs. Used for reliability estimation.
Covered in section on Software reliability.
Defect testing
Tests designed to discover system defects.
A successful defect test is one which reveals
the presence of defects in a system.
5
Ian Sommerville 1995
Some Terminology
Failure
A failure is said to occur whenever the external
behavior does not conform to system spec.
Error
An error is a state of the system which, in the
absence of any corrective action, could lead to a
failure.
Fault
An adjudged cause of an error.
6
Some Terminology
It is there in the program
Fault
Program state
Error
Observed
Failure
7
Testing Activities
Subsystem
Code
Subsystem
Code
Unit
Test
Unit
Test
Tested
Subsystem
Tested
Subsystem
Requirements
Analysis
Document
System
Design
Document
Integration
Test
Integrated
Subsystems
Functional
Test
User
Manual
Functioning
System
Tested Subsystem
Subsystem
Code
Unit
Test
All tests by developer
8
Test
Clients
Understanding
of Requirements
Accepted
System
Acceptance
Test
Tests by client
User
Environment
Installation
Test
Usable
System
Tests by developer
Users understanding
System in
Use
Tests (?) by user
Debugging Activities
Locate error
& fault
Design fault
repair
Repair fault
Re-test
program
11
Ian Sommerville 1995
Testing Activities
Identify
Design
Execute
Test result
12
13
Black-box Testing
Focus: I/O behavior. If for any given input, we can predict
the output, then the module passes the test.
Almost always impossible to generate all possible inputs ("test
cases")
White-box Testing
Statement Testing (Algebraic Testing): Test single statements
(Choice of operators in polynomials, etc)
Loop Testing:
Cause execution of the loop to be skipped completely. (Exception:
Repeat loops)
Loop to be executed exactly once
Loop to be executed more than once
Path testing:
Make sure all paths in the program are executed
Code Coverage
Statement coverage
Elementary statements: assignment, I/O, call
Select a test set T such that by executing P in all
cases in T, each statement of P is executed at
least once.
read(x); read(y);
if x > 0 then write(1);
else
write(2);
if y > 0 then write(3);
else
write(4);
T: {<x = -13, y = 51>, <x = 2, y = -3>}
16
}
/* Compute the mean and print the result */
7 if (NumberOfScores > 0) {
Mean = SumOfScores / NumberOfScores;
printf( The mean score is %f\n, Mean);
} else
printf (No scores found in file\n);
9
}
17
18
Unit Testing
Objective: Find differences between specified units and their imps.
Unit: component ( module, function, class, objects, )
Unit test environment:
Driver
Test cases
Unit under
test
Effectiveness?
Test result
Stub
Stub
Partitioning
Code coverage
Dummy modules
19
Integration Testing
Objectives:
To expose problems arising from the combination
To quickly obtain a working solution from components.
Problem areas
Internal: between components
Invocation: call/message passing/
Parameters: type, number, order, value
Invocation return: identity (who?), type, sequence
External:
Interrupts (wrong handler?)
I/O timing
Interaction
20
Integration Testing
Types of integration
Structural
Big bang no error localization
Bottom-up: terminal, driver/module, (driver
module)
Top-down: top, stubs, (stub module), early demo
Behavioral
(next slide)
21
Integration Testing
(Behavioral: Path-Based)
A
22
System Testing
Concerns with the apps externals
Much more than functional
Load/stress testing
Usability testing
Performance testing
Resource testing
23
System Testing
Functional testing
Objective: Assess whether the app does what it
is supposed to do
Basis: Behavioral/functional specification
Test case: A sequence of ASFs (thread)
24
System Testing
Functional testing: coverage
Event-based coverage
Data-based
DM1: Exercise cardinality of every relationship
DM2: Exercise (functional) dependencies among relationships
25
System Testing
Stress testing: push it to its limit + beyond
Volume
Users
:
Application
(System)
response
rate
Resources: phy. + logical
26
System Testing
Performance testing
Performance seen by
users: delay, throughput
System owner: memory, CPU, comm
Performance
Explicitly specified or expected to do well
Unspecified find the limit
Usability testing
Human element in system operation
GUI, messages, reports,
27
28
Acceptance Testing
Regression Testing
Whenever a system is modified (fixing a bug,
adding functionality, etc.), the entire test suite
needs to be rerun
Make sure that features that already worked are not
affected by the change
Black-box Testing:
Potential combinatorical explosion
of test cases (valid & invalid data)
Often not clear whether the selected
test cases uncover a particular error
Does not discover extraneous use
cases ("features")
31
Code inspection
Proofs (Design by Contract)
Black-box, white box,
Select integration testing
strategy (big bang, bottom up,
top down, sandwich)
Use implementation
knowledge about algorithms:
Examples:
Force division by zero
Use sequence of test cases for
interrupt handler
Control structures
Test branches, loops, ...
Data structures
Test records fields, arrays, ...
33
Unit-testing Heuristics
1. Create unit tests as soon as object
design is completed:
Black-box test: Test the use
cases & functional model
White-box test: Test the
dynamic model
Data-structure test: Test the
object model
2. Develop the test cases
Goal: Find the minimal
number of test cases to cover
as many paths as possible
3. Cross-check the test cases to
eliminate duplicates
Don't waste your time!
34