Download presentation
1
Software engineering for real-time systems
Section 11 Analysing and testing source code SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
2
Objectives Introduction To:
Explain the underlying concepts of the testing of source code. Describe the basics of static and dynamic analysis. Introduce code complexity metrics. Describe coverage analysis and its use as part of the dynamic analysis process. Illustrate test issues specifically related to object-oriented programming constructs. SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
3
Introduction to software testing
Part 1 Overview SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
4
Why test software? SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
5
Approaches to code testing
Detecting errors Preventing errors SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
6
Software code test techniques
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
7
Software testing steps
Integrate sub-systems then test the complete system Software system Software sub-system 1 Software sub-system 2 Major software function 1 function 2 function 3 Code unit 1 3 2 5 4 Integration of parts Integrate functions then test sub-systems Integrate units then test functions Test units SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
8
Introduction to static analysis
Part 2 Static Analysis SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
9
Static analysis techniques
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
10
Automated static analysis tools
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
11
Evaluating program structure - cyclomatic complexity measures
McCabe’s cyclomatic complexity metric: a measure of the amount of decision logic in a code unit Control flow graph Graph complexity measured using Cyclomatic complexity techniques Output from module Source code decision logic Input to module Structure described using a Cyclomatic complexity value: the number of independent paths through a control flow graph SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
12
Control flow graph - simple sequence structure
Corresponding flow Code of 'module' graph { Statement 1 Node 1 Accel [0] = Xnew; Edge (1-2) Accel [1] = Xold; Accel [2] = Ynew; Statement 2 Node 2 Edge } (2-3) Statement 1 Statement 2 Statement 3 Flowchart Statement 3 Node 3 Cyclomatic complexity value v(G): the number of independent paths through a control flow graph. Here v(G) = 1 SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
13
Control flow graph - simple selection structure
Statement Flowchart ? v(G) = 2 SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
14
Control flow graph - simple iteration structure
Code of 'module' Corresponding flow graph Node 1 { Edge (1-5) while (DataValue < 10) { Construct 1 Edge (1-2) cout << "\nInput data value"; cin >> DataValue' Construct 2 Node 2 Edge cout << DataValue; Edge (4-1) (2-3) } /* end while */ Construct 3 Node 3 Construct 4 cout << "\nEnd of test"; Edge (3-4) Construct 5 Node 4 } Statement Flowchart ? Node 5 v(G) = 2 SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
15
Example control flow graphs
simplest structure achievable Control flow graph - highly complex structure SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
16
Introduction to dynamic analysis
Part 3 Dynamic Analysis SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
17
Black box and white box testing
Two ways of testing code Overall function Internal workings ‘Black box’ testing Performed at the interfaces ‘White box’ testing Performed on the implementation SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
18
Basis of dynamic testing
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
19
The test harness SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
20
Features of general-purpose dynamic testing tools
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
21
Coverage analysis and white box testing
‘A measure of the effectiveness and completeness of code testing.’ SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
22
Basis of a practical dynamic testing tool
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
23
Dynamic testing and coverage analysis tool
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
24
Integration and testing
Part 4 Integration and test strategies SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
25
Combined unit and integration testing
Test code for unit A Test 2 Integrate units A1 and A2 to form A A1 Test 1(a) A2 Test 1(b) Phase 1: test individual units. Phase 2: test the combined unit. This test must exercise all features of A1 and A2. SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
26
Reduced integration testing
v Call node (a) Reducedl graph - v(G) = 2 v Reduction steps: 1. Identify ALL control structures of units A1 and A2 not concerned with external units (A). 2. Remove these from the flow graph. Call node (a) Original graph - v(G) = 6 Full flow graph of the integrated unit A. Reduced flow graph of the integrated unit SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
27
Class and object testing
Part 5 OO systems - Class and object testing SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
28
Class and object testing
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
29
OO metrics in general use
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
30
Use of OO metrics Use of OO metrics (class and object) Evaluation of
Estimation of Assessment of Prediction of required completeness and coding errors design complexity test effort self-containment Ÿ LOC Ÿ MHF Ÿ DIT Ÿ WMC Ÿ AD Ÿ AHF Ÿ NOC Ÿ RFC Ÿ MD Ÿ LCOM Ÿ LCOM Ÿ MHF Ÿ WMC Ÿ CBO SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
31
Inheritance, polymorphism and testing issues
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
32
Multiple clients using multiple servers having polymorphic methods
THE question: How much testing is needed? SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
33
Alternative test strategies with multiple clients/servers
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
34
Review of ‘Analysing and testing source code’
SOFTWARE ENGINEERING for REAL-TIME SYSTEMS (© J.E.Cooling 2003)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.