Introduction to Dynamic Analysis

Similar documents
Subject Software Testing Structural Testing

CS 520 Theory and Practice of Software Engineering Fall 2018

(See related materials in textbook.) CSE 435: Software Engineering (slides adapted from Ghezzi et al & Stirewalt

Chapter 11, Testing. Using UML, Patterns, and Java. Object-Oriented Software Engineering

Facts About Testing. Cost/benefit. Reveal faults. Bottom-up. Testing takes more than 50% of the total cost of software development

Reading assignment: Reviews and Inspections

Software Testing. Testing: Our Experiences

Structural Testing. (c) 2007 Mauro Pezzè & Michal Young Ch 12, slide 1

Page 1. Reading assignment: Reviews and Inspections. Foundations for SE Analysis. Ideally want general models. Formal models

Verification Overview Testing Theory and Principles Testing in Practice. Verification. Miaoqing Huang University of Arkansas 1 / 80

10. Software Testing Fundamental Concepts

Why testing and analysis. Software Testing. A framework for software testing. Outline. Software Qualities. Dependability Properties

Topics in Software Testing

Part I: Preliminaries 24

Program Analysis. Program Analysis

Testing! Prof. Leon Osterweil! CS 520/620! Spring 2013!

Homework #1, on the class web pages later today

In this Lecture you will Learn: Testing in Software Development Process. What is Software Testing. Static Testing vs.

MONIKA HEINER.

Ingegneria del Software Corso di Laurea in Informatica per il Management

Fachgebiet Softwaretechnik, Heinz Nixdorf Institut, Universität Paderborn. 4. Testing

An Introduction to Systematic Software Testing. Robert France CSU

Testing & Debugging TB-1

Test Case Specifications and Test adequacy. Research Methods - Barbara Russo SwSE - Software and Systems Engineering

XVIII. Software Testing. Laurea Triennale in Informatica Corso di Ingegneria del Software I A.A. 2006/2007 Andrea Polini

Testing. ECE/CS 5780/6780: Embedded System Design. Why is testing so hard? Why do testing?

Testing: Coverage and Structural Coverage

Chapter 10. Testing and Quality Assurance

Overview. State-of-the-Art. Relative cost of error correction. CS 619 Introduction to OO Design and Development. Testing.

Reading Assignment. Symbolic Evaluation/Execution. Move from Dynamic Analysis to Static Analysis. Move from Dynamic Analysis to Static Analysis

Symbolic Evaluation/Execution

Software Testing. Software Testing

STRUCTURAL TESTING. AKA White Box Testing. Thanks go to Andreas Zeller for allowing incorporation of his materials. F. Tip and M.

INTRODUCTION TO SOFTWARE ENGINEERING

Path Testing + Coverage. Chapter 8

Aerospace Software Engineering

Using the code to measure test adequacy (and derive test cases) Structural Testing

STRUCTURAL TESTING. AKA White Box Testing. Thanks go to Andreas Zeller for allowing incorporation of his materials. F. Tip and M.

Program Testing and Analysis: Manual Testing Prof. Dr. Michael Pradel Software Lab, TU Darmstadt

Testing: Coverage and Structural Coverage

CSE 403: Software Engineering, Fall courses.cs.washington.edu/courses/cse403/16au/ Unit Testing. Emina Torlak

Testing. CMSC 433 Programming Language Technologies and Paradigms Spring A Real Testing Example. Example (Black Box)?

Properties of Criteria. 1. Applicability Property. Criteria

Darshan Institute of Engineering & Technology for Diploma Studies

Testing. Prof. Clarkson Fall Today s music: Wrecking Ball by Miley Cyrus

Manuel Oriol, CHCRC-C, Software Testing ABB

White-Box Testing Techniques

Structural Testing. Testing Tactics. Why Structural? Structural white box. Functional black box. Structural white box. Functional black box

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

MTAT : Software Testing

Software Testing for Developer Development Testing. Duvan Luong, Ph.D. Operational Excellence Networks

Introduction to Problem Solving and Programming in Python.

Quality Assurance in Software Development

Specification-based Testing 2

Software Engineering 2 A practical course in software engineering. Ekkart Kindler

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Testing is executing a system in order to identify any gaps, errors, or missing requirements in contrary to the actual requirements.

INTRODUCTION TO SOFTWARE ENGINEERING

Structural Testing. White Box Testing & Control Flow Analysis

Testing: Test design and testing process

Program Verification! Goals of this Lecture! Words from the Wise! Testing!

Structural Testing. Testing Tactics. Why Structural? Structural white box. Functional black box. Structural white box. Functional black box

Testing! The material for this lecture is drawn, in part, from! The Practice of Programming (Kernighan & Pike) Chapter 6!

Announcements. Testing. Announcements. Announcements

Software Quality Assurance. David Janzen

Testing: (A Little) Logic Coverage

Testing Tactics. Structural Testing. Why Structural? Why Structural? Functional black box. Structural white box. Functional black box

UNIT-4 Black Box & White Box Testing

Three General Principles of QA. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Software Testing CS 408

Software Testing TEST CASE SELECTION AND ADEQUECY TEST EXECUTION

UNIT-4 Black Box & White Box Testing

Software Engineering and Scientific Computing

Darshan Institute of Engineering & Technology Unit : 9

Verification and Validation. Assuring that a software system meets a user s needs. Verification vs Validation. The V & V Process

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, September 18, ISSN SOFTWARE TESTING

Software Design Models, Tools & Processes. Lecture 6: Transition Phase Cecilia Mascolo

CMPSCI 521/621 Homework 2 Solutions

Principles of Software Construction: Objects, Design, and Concurrency (Part 2: Designing (Sub )Systems)

White-Box Testing Techniques III

Software Testing part II (white box) Lecturer: Giuseppe Santucci

Lecture 15 Software Testing

CMPT 473 Software Quality Assurance. Graph Coverage. Nick Sumner

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Terminology. There are many different types of errors and different ways how we can deal with them.

Testing & Symbolic Execution

Second assignment came out Monday evening. Find defects in Hnefetafl rules written by your classmates. Topic: Code Inspection and Testing

MTAT : Software Testing

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, April- ICITDA 18,

Software Verification and Validation. Prof. Lionel Briand Ph.D., IEEE Fellow

Test Case Selection and Adequacy

CS/ECE 5780/6780: Embedded System Design

MSc Software Testing MSc Prófun hugbúnaðar

Lecture 26: Testing. Software Engineering ITCS 3155 Fall Dr. Jamie Payton

6. Test-Adequacy. Assessment Using Control Flow and Data Flow. Andrea Polini

Administrivia. ECE/CS 5780/6780: Embedded System Design. Acknowledgements. What is verification?

MSc Software Testing and Maintenance MSc Prófun og viðhald hugbúnaðar

Dataflow-based Coverage Criteria

Software Testing Fundamentals. Software Testing Techniques. Information Flow in Testing. Testing Objectives

Software Testing. Massimo Felici IF

Transcription:

Introduction to Dynamic Analysis Reading assignment Gary T. Leavens, Yoonsik Cheon, "Design by Contract with JML," draft paper, http://www.eecs.ucf.edu/~leavens/jml//jmldbc.pdf G. Kudrjavets, N. Nagappan, T. Ball, Assessing the Relationship between Software Assertions and Code Quality: An Empirical Investigation, 17th International Symposium on Software Reliability Engineering (ISSRE), Raleigh, NC, 2006, pp. 204-212 Page 1

Static Analysis versus Dynamic Analysis Static Analysis -- the static examination of an artifact for the purpose of inferring properties or characteristics Dynamic Analysis -- the execution of artifact for the purpose of inferring properties or characteristics Testing -- the (systematic) selection and subsequent "execution" of sample inputs from a product's input space in order to infer information about the product's behavior. usually trying to uncover failures the most common form of dynamic analysis Approaches Dynamic Analysis Assertions Error seeding, mutation testing Coverage criteria Fault-based testing Regression testing Static Analysis Inspections Software metrics Symbolic execution Dependence Analysis Data flow analysis Software verification Page 2

Overview of Dynamic Analysis Techniques Testing Processes Testing Approaches Black Box versus White Box Black Box Strategies Test case selection criteria Representations for considering combinations of events/states White Box/Structural Test Data Selection Coverage based Fault-based Failure-based Common Testing Processes Unit testing-exercise a single simple component Procedure Class Integration testing-exercise a collection of interdependent components Focus on interfaces between components System testing-exercise a complete, stand-alone system Acceptance testing-customer s evaluation of a system Usually a form of system testing Regression testing-exercise a changed system Focus on modifications and their impact Page 3

Approaches to testing Black Box/Functional/Requirements based White Box/Structural/Implementation based White box testing process evaluation executable component (textual rep) test data selection criteria executable component (obj code) test cases execution results Requirements or specifications oracle testing report Page 4

Black box testing process evaluation executable component (textual rep) test data selection criteria executable component (obj code) test cases execution results Requirements or specifications oracle testing report Why black AND white box? Black box May not have access to the source code Often do not care how s/w is implemented, only how it performs Tests what a system should do, not just what it does do White box Want to take advantage of all the information Looking inside indicates structure=> helps determine weaknesses Page 5

Test Selection Criteria How do we determine what are good test cases? How do we know when to stop testing? Test Adequacy Test Selection Criteria A test set T is a finite set of inputs (test cases) to an executable component Let D( S ) be the domain of execution for program/ component/system S Let S(T) be the results of executing S on T A test selection criterion C(T,S) is a predicate that specifies whether a test set T satisfies some selection criterion for an executable component S. Thus, the test set T that satisfies the Criterion C is defined as: { tєτ Τ D(S) and C( T, S ) } Does not say anything about S(T) Page 6

Ideal Test Criterion A test criterion is ideal if for any executable system S and every T D( S ) such that C( T, S ), if S (T) is correct, then S is correct of course we want T<< D( S ) In general, T= D( S ) is the only test criterion that satisfies this ideal In general, there is no ideal test criterion Testing shows the presence, not the absence of bugs E. Dijkstra Dijkstra was arguing that verification was better than testing But verification has similar problems can't prove an arbitrary program is correct can't solve the halting problem can't determine if the specification is complete Need to use dynamic and static techniques that complement each another Page 7

Effectiveness a more reasonable goal A test criterion C is effective if for any executable system S and every T D (S ) such that C(T, S), if S (T) is correct, then S is highly reliable OR if S (T) is correct, then S is guaranteed (or is very likely) not to contain any faults of a particular type Currently can not do either of these very well Some techniques (static and dynamic) can provide some guarantees Stopping rule vs. Measurement C:(S,T) -> {true, false } C: (S,T) -> [0,1] stopping rule measurement Page 8

Zhu and Hall s Measurement Theory For all systems S and specifications R, the adequacy of the empty test is 0 the adequacy of exhaustive testing is 1 If test set t1 is a subset of test set t2, then the adequacy of t1 is less than or equal to the adequacy t2 (monotonicity) Two Uses for Testing Criteria Stopping rule--when has a system been tested enough E.g., C(S,T)>.8 Test data evaluation rule--evaluates the quality of the selected test data May use more than one criteria May use different criteria for different types of testing E.g.,regression testing versus acceptance testing Page 9

Black Box/Functional Test Data Selection Typical cases Boundary conditions/values Exceptional conditions Illegal conditions (if robust) Fault-revealing cases based on intuition about what is likely to break the system Other special cases Black Box Test Data Selection Stress testing large amounts of data worse case operating conditions Performance testing Combinations of events select those cases that appear to be more error-prone Select 1 way, 2 way, n way combinations Page 10

Sequences of events Common representations for selecting sequences of events Decision tables Use cases State diagrams/finite-state automata Decision Table events" t1" t2" t3" t5" t6" t7"..." e1" -" e2" e3" e4"..." -" -" No order to when the events occur Often used to described different states of the system Page 11

UML State Diagram Could also use use cases, message sequence chargs, activity diagrams, finitestate automaton or any diagram that depicts the flow through the system Outline: Dynamic Analysis Techniques Testing Processes Unit, Integration, System, Acceptance, Regression, Stress Testing Approaches Black Box versus White Box Black Box Strategies Test case selection criteria Representations for considering combinations of events/states Often done by a quality assurance (QA) group that reads the manual and tries to break the system White Box Stratgies Page 12

White Box/Structural Test Data Selection Coverage based Fault-based e.g., mutation testing, RELAY Failure-based domain and computation based use representations created by symbolic execution Coverage Criteria control-flow adequacy criteria G = (N, E, s, f) where the nodes N represent executable instructions (statement or statement fragments) the edges E represent the potential transfer of control s є N is a designated start node f є N is a designated final node E = { (n i, n j ) syntactically, the execution of n j follows the execution of n i } Page 13

Control-Flow-Graph-Based Coverage Criteria Statement Coverage Branch Coverage Path Coverage Hidden Paths Loop Guidelines General Boundary - Interior Statement Coverage requires that each statement in a program be executed at least once formally: a set P of paths in the CFG satisfies the statement coverage criterion iff n i є N, p є P such that n i is on path p This definition is in terms of paths test cases => a set of paths Page 14

Statement Coverage only about 1/3 of NASA statements were executed before software was released (Stucki 1973) usually can achieve 85% coverage easily, but why not 100%? unreachable code complex sequence (should be tested!) Microsoft reports 80-90% code coverage Infeasible Paths versus Unreachable Code 1 2 3 4 5 6 7 Unreachable code will not be reached on any executable path Page 15

How does OO affect coverage? Often only parts of a reused component are actually executed by a system Would expect good coverage for unit testing More restricted coverage for integration testing Coincidental Correctness Executing a statement does not guarantee that a fault on that path will be revealed Example: Y : = X * 2 but should be Y : = X * * 2 If x = 2 then the fault is not exposed Page 16

Branch Coverage Requires that each branch in a program (each edge in a control flow graph) be executed at least once e.g., Each predicate must evaluate to each of its possible outcomes Branch coverage is stronger than statement coverage Branch Coverage 1! 2! 3 STATEMENT COVERAGE: PATH 1, 2, 3! BRANCH COVERAGE: PATH 1, 2, 1, 2, 3! Page 17

Consider the following example If ( X > 1 ) ( Y < 2 ) then Test Data: X = 2, Y = 5 ->T X = 1, Y = 5 ->F Hidden Path (branch) Coverage Requires that each condition in a compound predicate be tested Example: T" ( X > 1 ) ( Y < 2 ) X > 1" F" Test Data: X = 2, Y = 5 ->T T" X = 1, Y = 5 ->F Y < 2" F" but, true branch is never tested for data where Y < 2. ( X > 1 )!( Y < 2 ) T! F! F! T! T! T! F! F! Page 18

Path Coverage Requires that every executable path in the program be executed at least once In most programs, path coverage is impossible Example: read N; SUM := 0; for I = 1 to N do read X; SUM := SUM + X; endfor How do we choose a set of paths? Loop Coverage Path 1, 2, 1, 2, 3 executes all branches (and all statements) but does not execute the loop well. 1" 2" 3" Page 19

Typical Guidelines for loop coverage fall through case minimum number of iterations minimum +1 number of iterations maximum number of iterations (if practical) 1" 2" 3" 1, 3 1,2,3 1,2,1,2,3 (1, 2,) n 3 Boundary - Interior Criteria boundary test of a loop causes the loop to be entered but not iterated interior test of a loop causes a loop to be entered and then iterated at least once both boundary and interior tests are to be selected for each unique path through the the loop Page 20

Example 1 8! 2! 3! 4! 5! 6! 7! Paths for Example Boundary paths 1,2,3,5,7 a 1,2,3,6,7 b 1,2,4,5,7 c 1,2,4,6,7 d Interior paths (for 2 executions of the loop) a,a a,b a,c a,d b,a b,b... x,y for x,y = a, b, c, d 1 2! 3! 4! 5! 6! 7! 8! Page 21

Selecting paths that satisfy these criteria static selection some of the associated paths may be infeasible dynamic selection monitors coverage and displays areas that have not been satisfactorily covered Problem with coverage criteria: Does not take into account the operational profile Companies care more about faults that occur in frequently executed code Could try to weight coverage criteria for frequently executed code more heavily Fault detection may depend upon Specific combinations of statements, not just coverage of those statements Astutely selected test data that reveals the fault, not just test data that executes the statement/branch/path Will look at semantically richer models Page 22

Benefits of structural coverage criteria Easy to monitor and measure Provides some guidance or evaluation of test cases Page 23