Integration Testing Notes
Integration Testing Notes
A B C
D E F
Integration Strategy
• Strategy impacts on
– the form in which units test-cases are written
– the type of test tools to use
– the order of coding/testing units
– the cost of generating test cases
– the cost of locating and correcting detected
defects
Integration testing strategies
• Non-incremental strategy
– Unit test each module in isolation
– Integrate as a whole
main test
main
A B C test
A
test
D E F B test
test main, A, B, C
C D, E, F
test
D
test
E
test
F
Big Bang Integration
• Advantages
– Convenient for small systems
• Disadvantages
– Need driver and stubs for each module
– Integration testing can only begin when all
modules are ready
– Fault localization difficult
– Easy to miss interface faults
Top-down Integration
• Incremental strategy
1. Start by including highest level
modules in test set. test
main
– All other modules replaced by
stubs or mock objects.
2. Integrate (i.e. replace stub by real
module) modules called by called by test
modules in test set. main, A,
B,C
3. Repeat until all modules in test set.
main
test
main, A, B, C
D, E, F
A B C
D E F
Top-down Integration
A B C
test
main, A,
C, D, E, F
D E F
test
main, A, B, C
D, E, F
Top-down Integration
• Advantages
– Fault localization easier
– Few or no drivers needed
– Possibility to obtain an early prototype
– Different order of testing/implementation possible
– Major design flaws found first
– in logic modules on top of the hierarchy
• Disadvantages
– Need lot of stubs / mock objects
– Potentially reusable modules (in bottom of the hierarchy)
can be inadequately tested
Bottom-up Integration
• Incremental strategy
– Test low-level modules, then
– Modules calling them until highest level module
test
main D test
D,E,A
A B C
test test
test
E main, A, B,
B
D E F
C
D, E, F
test test
F C,F
Bottom-up Integration
• Advantages
– Fault localization easier (than big-bang)
– No need for stubs / fewer mock objects
– Logic modules tested thoroughly
– Testing can be in parallel with implementation
• Dis-advantages
– Need drivers
– High-level modules (that relate to the solution logic)
tested in the last (and least)
– No concept of early skeletal system
Sandwich Integration
• Combines top-down and bottom-up approaches
• Distinguish 3 layers
– logic (top) - tested top-down
– middle
– operational (bottom) – tested bottom-up
test
main D test
D,E,A
A B C
test test
E main, A, B,
D E F
C
test test D, E, F
F C,F
test
main test
main, A, B, C
Modified Sandwich Integration
test
main test
main,A,B,C
test
B
Risk Driven integration
main
A B C
D E F
Integration of Object-Oriented
Systems
• Different scopes
– Intra Class (methods within a class)
– Big-bang
– Bottom-up: constructors - accessors - predicates - modifiers -
iterators – destructors
– State based integration
– Cluster Integration
– Big Bang
– Bottom-up
– Top-down
– Scenario based
– Subsystem/System Integration
– Big Bang
– Bottom-up
– Top-down
– Use case based
Intra-Class Integration
• Integration of methods
– Big-bang indicated for situation where methods are
tighly coupled
– complex methods can be tested with stubs/mocks
Cluster Integration
FinancialService
Transaction Account
IntCollection
Cluster Integration
Big Bang approach
• Recommended only when:
– Cluster is stable, only few elements added or
changed
– Small cluster
– Components are very tighly coupled
– Impossible to test separately in practice
Cluster Integration
Bottom-up approach
• Most widely used technique
– moving up in
test
– dependency tree
Transaction,
Rate,Money,
test IntCollection
Money test
FinancialService,
FinancialService Transaction,
Account,Money
AcctNum,Rate
Transaction Account test IntCollection
Account,Money
AcctNum
Rate Money AcctNum
test
IntCollection
AcctNum
Cluster Integration
Top-down Integration
• Possible only when there is a head class
• Approach
1. Map collaborations onto dependency tree
2. Choose a sequence to apply collaborations. For example:
– simplest first
– fewest stubs first
– etc.
3. Develop and run test exercising collaboration
Cluster Integration
Scenario based approach
• Collaboration 1
– FinancialService,
Transaction, Rate,
FinancialService
InCollection
Transaction Account
– Stubs for: Account,
Money, AcctNum
Rate Money AcctNum
• Collaboration 2
– FinancialService,
IntCollection
Account, Money,
AcctNum
– Stubs for:
Transaction, Rate,
IntCollection
Problems related to inheritance (1)
• Accidental reuse
– Using an inherited method when it was not
intended to do so.
Problems related to inheritance (2)
• Multiple inheritance
– Multiple test-cases needed
– Possibility of incorrect binding
– Repeated inheritance
• Abstract classes
– Cannot be instantiated directly.
• Generic classes
Example
• Bottom-up integration
– works well for small/medium systems
• Top-down integration
client 1 client 3
server
client 2 client 4
Client/Server integration
Three-tier System
• Test each client with stubs for servers, and the middle-tier.
• Test server with stubs for each client types, and the middle-tier.
• Test each client with middle-tier and server proxy.
• Test server with middle-tier and client proxy.
• Test clients with middle-tier and the actual server.
Middle Tier
server