Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt www.introsoftwaretesting.com.

Slides:



Advertisements
Similar presentations
Introduction to Software Testing Chapter 1
Advertisements

Introduction to Software Testing Chapter 1 Model-Driven Test Design Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.3 Logic Coverage from Source Code Paul Ammann & Jeff Offutt.
Introduction to Software Testing Chapter 1 Paul Ammann & Jeff Offutt SUMMARY OF PARTS 1 AND 2 FROM LAST WEEK.
Paul Ammann & Jeff Offutt
Graph Coverage (2).
Introduction to Software Testing Chapter 9.2 Challenges in Testing Software – Software Testability Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.1, 2.2 Overview Graph Coverage Criteria Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.6 Graph Coverage for Use Cases Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.7 Representing Graphs Algebraically Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Coverage tools Program is typically compiled with special options, to add extra source or object code. –Additional data structures, such as a flow graph,
Introduction to Software Testing Chapter 2.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
Introduction to Software Testing
Overview Graph Coverage Criteria ( Introduction to Software Testing Chapter 2.1, 2.2) Paul Ammann & Jeff Offutt.
Software Testing and Maintenance Lecture 4 Graph Coverage for Design Element Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
1 Graph Coverage (4). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section
Introduction to Software Testing Chapters 1-5 Coverage Summary Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Introduction to Software Testing (2nd edition) Chapter 7.4 Graph Coverage for Design Elements Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt.
Software Testing and Maintenance Lecture 2.1 Overview Graph Coverage
White Box Testing Arun Lakhotia University of Southwestern Louisiana P.O. Box Lafayette, LA 70504, USA
Introduction to Software Testing Chapter 9.2 Program-based Grammars Paul Ammann & Jeff Offutt
1 Graph Coverage (3). Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Section 2.2 ◦ Section
Workshop on Integrating Software Testing into Programming Courses (WISTPC14:2) Friday July 18, 2014 Introduction to Software Testing.
Paul Ammann & Jeff Offutt
Coupling-based Criteria for Integration Testing Journal of Software Testing, Verification, and Analysis, 8(3): , September 1998, Jenny Jin and Jeff.
Software Testing and Maintenance Lecture 3 Graph Coverage for Source Code Paul Ammann & Jeff Offutt Instructor: Hossein Momeni Mazandaran.
Data Flow Testing. Introduction to Software Testing (Ch 2) © Ammann & Offutt 2 Definition of a Graph A set N of nodes, N is not empty A set N 0 of initial.
© Dr. A. Williams, Fall Present Software Quality Assurance – Clover Lab 1 Tutorial / lab 2: Code instrumentation Goals of this session: 1.Create.
Introduction to Software Testing Model-Driven Test Design and Coverage testing Paul Ammann & Jeff Offutt Update.
Software Testing and Quality Assurance Practical Considerations (1) 1.
Software Testing and Quality Assurance Syntax-Based Testing (2) 1.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 9.2 Program-based Grammars
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.5 Logic Coverage for FSMs
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.1 Syntax-based Testing
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 5.2 Program-based Grammars
Introduction to Software Testing Chapter 3, Sec# 3.5
Paul Ammann & Jeff Offutt
Introduction to Software Testing Chapter 3.5 Logic Coverage for FSMs
Graph Coverage for Design Elements CS 4501 / 6501 Software Testing
Graph Coverage for Source Code
Paul Ammann & Jeff Offutt
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Logic Coverage for Source Code CS 4501 / 6501 Software Testing
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Paul Ammann & Jeff Offutt
Presentation transcript:

Introduction to Software Testing Chapter 8.1 Building Testing Tools –Instrumentation Paul Ammann & Jeff Offutt

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 2 Chapter 8 Outline 1.Instrumentation for Graph and Logical Expression Criteria 2.Building Mutation Testing Tools Instrumentation for Graph and Logical Expression Criteria

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 3 Categories of Test Tools Research Private non-commercial Commercial Advanced techniques Generators Very powerful Often code-based Usually incomplete General purpose Moderate techniques Acceptors Mostly complete Some code-based Often special purpose Test management Simple coverage Metrics Code independent

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 4 Types of Test Tools 1.Coverage analyzers (Acceptors) –What coverage ? (most common is node) –What level? (sometimes object code) 2.Flow graph generators 3.Metrics 4.Instrumentation support 5.Test execution automation –Runs scripts and reports results –JUnit, HttpUnit, … 6.Capture / replay –Useful for GUIs 7.Stubs and Drivers 8. Test data generators –Graph path – based –Data flow –Logic based –Functional –Mutation –Random –Only random test data generators exist

Tools Instrumentation The key technology behind many test tools is “instrumentation”

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 6 Tools Instrumentation Coverage analysis is measured with instrumentation Instrument : One or more statements inserted into the program to monitor some aspect of the program –Must not affect the behavior –May affect timing –Source level or object code level public int min (int A, B) { int m = A; if (A > B) { m = B; } return (m); } Mark: “if body is reached”

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 7 Instrumenting for Statement Coverage 1.Each node is given a unique id # –Node # or statement # 2.Create an array indexed by id #s – nodeCover [ ] 3.Insert an instrument at each node –nodeCover [ i ] ++; 4.Save nodeCover [ ] after each execution –Must accumulate results across multiple test cases

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 8 Statement Coverage Example int nodeCover[] = {0,0,0,0,0,0,0,0,0,0} nc [3]++ nc [2]++ nc [5]++ nc [4]++ nc [6]++ nc [9]++ nc [7]++ nc [10]++ nc [8]++ Read (nodeCover []) nodeCover [1] ++ After running a sequence of tests, any node for which nodeCover[node]==0 has not been covered.

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 9 Edge Coverage Instrumentation int edgeCover[] = {0,0,0,0,0,0,0,0,0,0,0,0,0} ec [2]++ ec [1]++ ec [3]++ Read (edgeCover []) For each edge e, put edgeCover[e]++ on the edge. If edgeCover[e] == 0, e has not been covered. Note that the arrays could be boolean

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 10 CACC_Mark_1 (A, B) { if (!A) { // Don’t allow short circuit if (B) CACCCover[1]++; } else if (A) { if (B) CACCCover [2]++; else CACCCover[3]++ } } CACC Coverage Instrumentation if (A && B) if (C && (D || E)) CACC_Mark_1 (A, B) CACC_Mark_2 (C, D, E) A && B CACCCover [ ] F t 1 T t 2 t F 3 t T

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 11 CACC Coverage Instrumentation (2) CACC_Mark_2 (C, D, E) { if (! C) { if (D || E) CACCCover [4]++; } else if (! D) { if (! E) CACCCover [6]++; else { CACCCover [5]++; CACCCover [8]++; } else // C and D if (! E) { CACCCover [5]++; CACCCover [7]++; } else CACCCover [5]++; } C && (D || E) CC [ ] F 4 T 5 t F f 6 t T f 7 t f F t f T 8 t t t f f t

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 12 All-Uses Coverage Instrumentation def (x, y) use (x) def (y) use (y) useCover [5, x, defCover[x]] ++ useCover [4, x, defCover[x]] ++ useCover [6, y, defCover[y]] ++ defCover [x] = 1 defCover [y] = 1 defCover [y] = 2 For each variable, keep track of its current def location. At each use, increment a counter for the def that reached it.

Introduction to Software Testing (Ch 8.1), © Ammann & Offutt 13 Instrumentation Summary Instrumentation can be added in multiple copies of the program –Source code –Java byte code (or other intermediate code) –Executable Instrumentation must not change or delete functionality –Only add new functionality Instrumentation may affect timing behavior Requires the program to be parsed –Once parsed, inserting instruments is straightforward Most challenging part is the user interface –Present reports as dumps of instrument arrays ? –Present tables ? –Program source with colored annotations ? –Graph of program with colored annotations ?