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

Similar documents
Testing Methods: White Box Testing II

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

MTAT : Software Testing

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

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

Path Testing + Coverage. Chapter 8

Introduction to Dynamic Analysis

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

Subject Software Testing Structural Testing

CS 520 Theory and Practice of Software Engineering Fall 2018

Structural Testing. White Box Testing & Control Flow Analysis

MTAT : Software Testing

c. Typically results in an intractably large set of test cases even for small programs

Testing: Coverage and Structural Coverage

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

Introduction to Software Testing Chapter 2.3 Graph Coverage for Source Code. Paul Ammann & Jeff Offutt

Testing: Coverage and Structural Coverage

Testing: (A Little) Logic Coverage

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

Overview Graph Coverage Criteria

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

Software Testing Prof. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur. Lecture 13 Path Testing

Network Architecture Laboratory

Compiler Construction 2010/2011 Loop Optimizations

Python review. 1 Python basics. References. CS 234 Naomi Nishimura

Programming Embedded Systems

Software Testing. Testing: Our Experiences

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

MTAT : Software Testing

Improving Test Suites via Operational Abstraction

Computer Science and Software Engineering University of Wisconsin - Platteville 9-Software Testing, Verification and Validation

Darshan Institute of Engineering & Technology for Diploma Studies

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

SFWR ENG 3S03: Software Testing

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

White Box Testing III

Lecture 20: SW Testing Presented by: Mohammad El-Ramly, PhD

Compiler Construction 2009/2010 SSA Static Single Assignment Form

CMPSCI 521/621 Homework 2 Solutions

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

Compiler Construction 2016/2017 Loop Optimizations

Manju Muralidharan Priya. CS4PM Web Aesthetics and Development WEEK 12

ELEC 876: Software Reengineering

Research Collection. Overapproximating the Cost of Loops. Master Thesis. ETH Library. Author(s): Schweizer, Daniel. Publication Date: 2013

Announcements. Testing. Announcements. Announcements

Class 6. Review; questions Assign (see Schedule for links) Slicing overview (cont d) Problem Set 3: due 9/8/09. Program Slicing

Profile-Guided Program Simplification for Effective Testing and Analysis

Advanced Test Coverage Criteria: Specify and Measure, Cover and Unmask

Engineering Innovation Center LabVIEW Basics

MTAT : Software Testing

Introduction to Software Engineering

Automated White-Box Testing Beyond Branch Coverage

CMPT 473 Software Quality Assurance. Graph Coverage. Nick Sumner

Testing Methods: White Box Testing I

Dataflow-based Coverage Criteria

Properties of Criteria. 1. Applicability Property. Criteria

Using Automated Performance Modeling to Find Scalability Bugs in Complex Codes

Conditional Elimination through Code Duplication

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

Static program checking and verification

Introduction to Problem Solving and Programming in Python.

Data Flow Analysis. Daqing Hou

Software Testing. Massimo Felici IF

Research Incubator: Combinatorial Optimization. Dr. Lixin Tao December 9, 2003

White-Box Testing Techniques

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

Class 17. Discussion. Mutation analysis and testing. Problem Set 7 discuss Readings

Chapter 1: Introduction

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

CMSC 201 Spring 2017 Lab 12 Recursion

Compiler Design Spring 2017

Combining Analyses, Combining Optimizations - Summary

MTAT : Software Testing

White-Box Testing Techniques II

SE 3S03 - Tutorial 10. Helen Brown. Week of Mar 23, 2015

Chapter 9. Software Testing

Testing & Symbolic Execution

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

Symbolic Evaluation/Execution

UNIT-4 Black Box & White Box Testing

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

Agile Software Development. Lecture 7: Software Testing

Chapter 14 Testing Tactics

A Survey of Approaches for Automated Unit Testing. Outline

MPATE-GE 2618: C Programming for Music Technology. Syllabus

UNIT-4 Black Box & White Box Testing

Lecture 3 Local Optimizations, Intro to SSA

Compatible Qualification Metrics for Formal Property Checking

LESSON 3. In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script.

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

Testing Theory. Agenda - What will you learn today? A Software Life-cycle Model Which part will we talk about today? Theory Lecture Plan

INTRODUCTION TO SOFTWARE ENGINEERING

Introduction au Génie Logiciel Partie3: Test: Static White-Box Test

Smart Test Case Quantifier Using MC/DC Coverage Criterion

Motivation. Both human- and computer-generated programs sometimes contain data-flow anomalies.

Advanced Software Testing Understanding Code Coverage

Higher-order Testing. Stuart Anderson. Stuart Anderson Higher-order Testing c 2011

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

Iteration and Arrays Dr. Abdallah Mohamed

MTAT : Software Testing

Transcription:

Program Testing and Analysis: Manual Testing Prof. Dr. Michael Pradel Software Lab, TU Darmstadt Partly based on slides from Peter Müller, ETH Zurich 1

Warm-up Quiz What does the following code print? var a, b; var x = {}; x[a] = 23; console.log(x[b]); Nothing 23 undefined false 2

Warm-up Quiz What does the following code print? var a, b; var x = {}; x[a] = 23; console.log(x[b]); Nothing 23 undefined false 2

Warm-up Quiz What does the following code print? var a, b; var x = {}; x[a] = 23; console.log(x[b]); Have value undefined Write and then read undefined property of x Nothing 23 undefined false 2

Outline (Manual Testing) Overview Control flow testing Statement coverage Branch coverage Path coverage Loop coverage Data flow testing DU-pair coverage Interpretation of coverage 3

Path Coverage Idea: Test all possible paths through the CFG cov path = Nb. of executed paths T otal nb. of paths A path is a sequence n 1,.., n k where n 1 = entry node n k = exit node There is an edge n i n i+1 for all 1 i < k 4

Path Coverage: Example function fourpaths(a, b) { var x = 1; var y = 1; if (a) x = 0; else y = 0; if (b) return 5 / x; else return 5 / y; } 5

Path Coverage: Discussion Is path coverage the solution? function contains(a, x) { if (!a) return false; var found = false; for (var i = 0; i <= a.length; i++) { if (a[i] === x) { found = true; break; } } return found; } 6

18

Path Coverage: Discussion (2) Leads to more thorough testing than both statement and branch coverage Complete path coverage implies complete statement coverage and branch coverage But: at least n% path coverage implies neither at least n% statement coverage nor at least n% branch coverage Complete path coverage is not feasible for loops: Unbounded number of paths 8

Loop Coverage Idea: For each loop, test 0, 1, or more than 1 consecutive iterations Let n k be the number of loops with exactly k consecutively executed iterations cov loop = n 0 + n 1 + n >1 T otal nb. of loops 3 Typically combined with other criteria, such as statement or branch coverage 9

19

Measuring Coverage Coverage information is collected while the test suite executes Typically implemented via code instrumentation or debug interface Count executed basic blocks, branches taken, etc. 11

Measuring Coverage: Example function fourpaths(a, b) { var x = 1; var y = 1; if (a) { x = 0; } else { y = 0; } if (b) { return 5 / x; } else { return 5 / y; } } 12

Measuring Coverage: Example function fourpaths(a, b) { var x = 1; var y = 1; if (a) { executedbranches[0]++; x = 0; } else { executedbranches[1]++; y = 0; } if (b) { executedbranches[2]++; return 5 / x; } else { executedbranches[3]++; return 5 / y; } } 12

20

Outline Overview Control flow testing Statement coverage Branch coverage Path coverage Loop coverage Data flow testing DU-pair coverage Interpretation of coverage 14

Data Flow Testing Problem: Testing all paths is not feasible Number grows exponentially in the number of branches Loops Idea: Test those paths where a computation in one part of the path affects the computation of another part 15

Variable Definition and Use A variable definition for a variable v is a basic block that assigns to v v can be a local or global variable, parameter, or property A variable use for a variable v is a basic block that reads the value of v In conditions, computations, output, etc. 16

Definition-Clear Paths A definition-clear path for a variable v is a path n 1,.., n k in the CFG such that n 1 is a variable definition for v n k is a variable use for v No n i (1 < i k) is a variable definition for v n k may be a variable definition if each assignment to v occurs after a use Note: Def-clear paths do not go from entry to exit (in contrast to our earlier definition of paths) 17

Definition-Use Pair A definition-use pair (DU-pair) for a variable v is a pair of nodes (d, u) such that there is a definition-clear path d,.., u in the CFG 18

21

DU-Pairs Coverage Idea: Test all paths that provide a value for a variable use cov DU = Nb. of executed DU-pairs T otal nb. of DU-pairs 20

22

DU-Pair Coverage: Discussion Complements control flow testing Use both: Choose tests that maximize branch and DU-pair coverage As with path coverage, not all DU-pairs are feasible Static analysis overapproximates data flow Complete DU-pair coverage does not imply that all bugs are detected 22

Outline Overview Control flow testing Statement coverage Branch coverage Path coverage Loop coverage Data flow testing DU-pair coverage Interpretation of coverage 23

Interpreting Coverage High coverage does not imply that code is well tested But: Low coverage means that code is not well tested Do not blindly increase coverage but develop test suites that are effective at detecting bugs 24

Empirical Evidence Studies on the benefit of coverage metrics E.g., Andrews et al.: Using Mutation Analysis for Assessing and Comparing Testing Coverage Criteria, 2006 Approach Seed bugs into code Develop test suites that satisfy various coverage criteria Measure how many of the seeded bugs are found 25

Empirical Evidence (2) The higher the coverage, the more bugs are detected Tests written with coverage criteria in mind are more effective than random tests (for the same test suite size) Test suite size grows exponentially in the achieved coverage 26

Summary: Manual Testing Black box testing Exhaustive testing Random testing Functional testing White box testing Structural testing Control flow-based coverage criteria: Statements, branches, paths, loops Data flow-based coverage criterion: DU-pairs 27