Integration Testing: Stuart Anderson
Integration Testing: Stuart Anderson
Stuart Anderson
Stuart Anderson
Integration Testing
c 2011
Stuart Anderson
Integration Testing
c 2011
Stuart Anderson
Integration Testing
c 2011
What is the Goal? Making the system secure by removing safety-related errors. How? Find the source of the problem
Stuart Anderson Integration Testing c 2011
Root Causes
Stuart Anderson
Integration Testing
c 2011
Stuart Anderson
Integration Testing
c 2011
Human Errors
Stuart Anderson
Integration Testing
c 2011
Process Flaws
Stuart Anderson
Integration Testing
c 2011
10
Stuart Anderson
Integration Testing
c 2011
11
Stuart Anderson
Integration Testing
c 2011
12
(Myers) Comparison
13
(Non-)Incremental Strategies
1. Non-incremental testing requires the creation of more scaolding. In particular if we test incrementally bottom-up we require fewer stub programs. 2. Incremental testing reveals errors and misunderstandings across interfaces earlier than non-incremental approaches. 3. Incremental testing should lead to earlier identication of problems and easier debugging. 4. Incremental testing should be more thorough since each increment fully tests some behavioural specication of a sub-component of the system (whereas non-incremental testing tests just the overall functionality). 5. Non-incremental may make more eective use of test eort since it focuses on the system behaviour. 6. Non-incremental test might encourage more concurrency in doing the testing.
Stuart Anderson
Integration Testing
c 2011
14
Stuart Anderson
Integration Testing
c 2011
15
Stuart Anderson
Integration Testing
c 2011
16
17
Stuart Anderson
Integration Testing
c 2011
18
Top-down Testing
Advantages If major defects are more likely at the top level modules top-down is benecial. Getting I/O functions in early can ease test writing. Early demonstration of the main functionality can be helpful in highlighting requirements issues and in boosting morale
Stuart Anderson
Disadvantages Too much eort on stubs. Stub complexity can introduce errors. Dening stubs can be dicult if some code is yet to be written. It may be impossible accurately to reproduce test conditions. Some observations may be impossible to make. Encourages the idea that test and development can overlap. Encourages deferring full testing of modules (until lower level modules are complete).
Integration Testing c 2011
19
Bottom-up Testing
Initiate testing with unit tests for the bottom modules in the dependency graph. Candidates for inclusion in the next batch of tests depend on the dependency structure a module can be included if all the modules it depends on have been tested (issue about potential circularity need to consider connected components). Prioritisation of modules for inclusion in the test sequence should include their criticality to the correct operation of the system.
Stuart Anderson
Integration Testing
c 2011
20
Stuart Anderson
Integration Testing
c 2011
21
Bottom-up Testing
Advantages Helpful if errors are likely deep down in the dependency structure (e.g. in hardware specic code). Test conditions are easier to create. Observation of test results is reasonably easy. Reduced eort in creating stub modules. Disadvantages Need to create driver modules (but arguably this is easier than creating stub code and tools like JUnit help). The entire system is subjected to the smallest amount of test (because the top modules are included in the tests at the nal stage).
Stuart Anderson
Integration Testing
c 2011
22
Hybrid Strategies
It is clear that judicious combination of stubs and drivers can be used to integrate in a middle-out approach. Also for some groups of modules we may want to take a non-iterative approach and just consider testing them all at once (this means we choose a bigger granularity for our integration steps). Using such approaches there are a range of potential criteria for deciding how to group modules: Criticality: decide on groups of modules that provide the most critical functionality and choose to integrate those rst. Cost: look for collections of modules with few dependencies on code lower in the dependency graph and choose to integrate there rst. The goal here is to reduce the cost of creating stub code.
Stuart Anderson
Integration Testing
c 2011
23
Adequacy criteria
Recall the denitions of coupling and cohesion from earlier software engineering courses. Both are qualitative measures of the properties of dependencies and module structure in programs. They are used to assess the quality of the modular structure of a system: Cohesion: is a measure of how strongly elements in a module relate to one another. Generally we expect to see elements in a module having high cohesion with one another and lower level of relatedness to objects outside the module. Coupling: is a measure of relatedness of the objects in a module to other modules. Generally we expect to see low coupling to other modules. If we identify elements in a system that contribute to coupling (this is a whitebox measure) then we might be able to dene coverage criteria for integration tests.
Stuart Anderson Integration Testing c 2011
Kinds of Coupling
24
25
26
Examples
27
Coupling paths from A to B here are: A1-B1 (A-if1 false, A-if2 false) A1-B1 (A-if1 true, A-if2 false) A1-B2 (A-if1 false , A-if2 false) A1-B2 (A-if1 true , A-if2 false) A2-B1 A2-B2 All-coupling-defs would be satised by a test which included, e.g. A1-B1 (A-if1 false, A-if2 false) and A2-B1. All-coupling-uses would be satised by a test which included A1-B1 (A-if1+, A-if2-), A1-B2 (A-if1-, A-if2-), A2-B1, and A2-B2.
Integration Testing c 2011
Stuart Anderson
28
29
Stuart Anderson
Integration Testing
c 2011
30
Summary
We can choose a range of strategies involving non-incremental and incremental approaches. Incremental approaches need to decide on the direction, sequence and granularity of the steps. There is a wide range of choice in integration steps. Integration testing has been relatively little studied and there are very few good support tools. One approach to providing guidance on the adequacy of integration testing is to use coupling-based coverage measures. This has been the subject of recent research. We should view the sequence and scaolding code as part of the system release. We can use data collected on faults detected in the eld to modify the integration sequence to provide more adequate testing of error-prone parts of the system.
Stuart Anderson Integration Testing c 2011
31
Required Readings
Textbook (Pezz` e and Young): Chapter 21, Integration and Componentbased Software Testing Textbook (Pezz` e and Young): (beginning of) Chapter 15, Testing ObjectOriented Software Robyn R. Lutz, Analyzing Software Requirements Errors in Safety-Critical, Embedded Systems, In Proceedings of the IEEE International Symposium on Requirements Engineering. IEEE Computer Society Press, Jan, 1993. http://dx.doi.org/10.1109/ISRE.1993.324825 Je Outt, Aynur Abdurazik and Roger T. Alexander (2000). An Analysis Tool for Coupling-based Integration Testing, The Sixth IEEE International Conference on Engineering of Complex Computer Systems (ICECCS 00), pp 172178. http://dx.doi.org/10.1109/ICECCS.2000.873942
Stuart Anderson Integration Testing c 2011
32
Example
CouplingDemo1
package st.coupling; import java.util.Locale; public class CouplingDemo { public static void main(String[] args) { Locale l = Locale.getDefault(); if(l.getLanguage().equals("en")) { System.out.println("Hi there! I " + "speak English too!"); } String d = Tools.localisedDistance(l, 200); System.out.println("Distance: " + d); } } package st.coupling; import java.util.Locale; public class Tools { public static String localisedDistance( Locale l, double metres) { String ld; if(! l.getLanguage().equals("en")) System.out.println("Warning: " + "non-English, assuming km"); if(l.getLanguage().equals("en")) ld = (metres / 1600) + "mi"; else ld = (metres / 1000) + "km"; return ld; } }
Tools
Stuart Anderson
Integration Testing
c 2011
33
Example
CouplingDemo2
package st.coupling; import java.util.Locale; public class CouplingDemo { public static void main(String[] args) { Locale l = Locale.GERMAN; if(l.getLanguage().equals("en")) { System.out.println("Hi there! I " + "speak English too!"); } String d = Tools.localisedDistance(l, 200); System.out.println("Distance: " + d); } } package st.coupling; import java.util.Locale; public class Tools { public static String localisedDistance( Locale l, double metres) { String ld; if(! l.getLanguage().equals("en")) System.out.println("Warning: " + "non-English, assuming km"); if(l.getLanguage().equals("en")) ld = (metres / 1600) + "mi"; else ld = (metres / 1000) + "km"; return ld; } }
Tools
Stuart Anderson
Integration Testing
c 2011