Академический Документы
Профессиональный Документы
Культура Документы
Lecture – 10
Agenda
Wrap-up
Conclusion
– Structural Testing
– Unit Testing
From Unit to Integration Testing
– OO Protocol Testing
– Finite State Machines for Testing
1
5/10/2019
2
5/10/2019
OO Protocol
Procedural software
– unit = single program, function, or procedure
Object oriented software
– unit = class
– unit testing = intra-class testing
– integration testing = inter-class testing (cluster of
classes)
dealing with single methods separately is usually
– too expensive (complex scaffolding)
Therefore, methods are usually tested in the
context of the class they belong to
3
5/10/2019
4
5/10/2019
Arranging transitions
Initial -> Empty: action = “create”
– e.g. “s = new Stack()” in Java
Empty -> Holding: action = “add”
Empty -> Full: action = “add”
– if MAXcapacity=1
Empty -> Final: action = “destroy”
– e.g. destructor call in C++, garbage collection in
Java
Holding -> Empty: action = “delete”
– if s.size() = 1
5
5/10/2019
Fault types
• Missing or incorrect
– Transitions – new state is legal but incorrect
– Events – valid message ignored
• Extra, missing or corrupt state
• Sneak path
• Illegal message failure
• Trap door
6
5/10/2019
Coverage Criteria
We can choose one or more of the following test
selection criteria:
All states – testing passes through all states
All events – testing forces all events to occur
at least once
All actions – testing forces all actions to be
produced at least once
Test Strategies
Possible strategies
– All round-trip paths
– All transition sequences beginning and ending in
the same state
– All simple paths from initial to final state
This strategy will help you to find
– All invalid or missing states
– Some extra states
– All event an action faults
7
5/10/2019
Question?
What if Account
– we have concept level status: enum
balanace: int
documents to consider isActive(): boolean
– Could be isBlocked(): boolean
isClosed(): boolean
UML documents gotBalance(): int
Specifications block()
unblock()
etc. close()
deposit(amount: int)
withdraw(amount: int)
Answer!
We develop state-machines considering these
artifacts…
But how…
Account
status: enum
balanace: int
isActive(): boolean
isBlocked(): boolean
isClosed(): boolean
gotBalance(): int
block()
unblock()
close()
deposit(amount: int)
withdraw(amount: int)
8
5/10/2019
MODEL-BASED TESTING
Models
• A model is a description of a system’s behavior.
• Models are simpler than the systems they
describe.
• Models help us understand and predict the
system’s behavior.
• For Testing:
• State-machines as models
• Specifications as models e.g., UML diagrams
• Formal Specifications as models e.g., Object Z
• …
9
5/10/2019
Specifications:
The answer will help test team to establish a clear relationship between
the system under test, the specification and the objective to satisfy.
Conformance testing
conformance relation
abstract abstract
model of S model of I
assumptions/ assumptions/
test hypothesis test hypothesis
conformance relation
precise implementation I
specification S
10
5/10/2019
Fault Models
A fault model is a hypothetical model of what types of faults
may occur in an implementation
– Most fault models are "structural", i.e. the model is a refinement of
the specification formalism (or of an implementation model)
E.g. mutations of the specification or of a correct implementation
– It may be used to construct the fault domain used for defining what
"complete test coverage" means
E.g. single fault hypothesis (or multiple faults)
A fault model is useful for the following problems:
– Test suite development for given coverage objective
– Formalization of "test purpose"
– For existing test suite: coverage evaluation and optimization
– Diagnostics
11
5/10/2019
12
5/10/2019
13
5/10/2019
Summary
Unit Testing – Conclusion
OO Protocol Testing
State-Machine based testing
Model-based testing
Next Lectures
– Specification-based Testing
– Grey-box testing: An Introduction
– Testing Classes Clusters
Method-Message Path Testing
– Testing Object-Oriented Systems
14