CS 520 Theory and Practice of Software Engineering Fall 2018

Similar documents
MTAT : Software Testing

Subject Software Testing Structural Testing

White Box Testing III

Introduction to Dynamic Analysis

Testing & Symbolic Execution

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

Testing: Coverage and Structural Coverage

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

Testing, Fuzzing, & Symbolic Execution

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Manuel Oriol, CHCRC-C, Software Testing ABB

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

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

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

MTAT : Software Testing

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

Ingegneria del Software Corso di Laurea in Informatica per il Management

Testing: Coverage and Structural Coverage

Software Testing. Massimo Felici IF

CS159. Nathan Sprague. September 30, 2015

MTAT : Software Testing

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

Software Testing. Testing: Our Experiences

Part I: Preliminaries 24

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

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

What is Mutation Testing? Mutation Testing. Test Case Adequacy. Mutation Testing. Mutant Programs. Example Mutation

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

Aerospace Software Engineering

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

Testing Methods: White Box Testing II

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

Testing Process and Methods. CS 490MT/5555, Spring 2017, Yongjie Zheng

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

CMPSCI 521/621 Homework 2 Solutions

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

Introduction to Software Testing Chapter 5.1 Syntax-based Testing

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

What is Mutation Testing?

UNIT-4 Black Box & White Box Testing

linaye/gl.html

CS 4387/5387 SOFTWARE V&V LECTURE 4 BLACK-BOX TESTING

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

UNIT-4 Black Box & White Box Testing

INTRODUCTION TO SOFTWARE ENGINEERING

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

Software Testing TEST CASE SELECTION AND ADEQUECY TEST EXECUTION

Testing Role in Unified Approach Coverage: Structural/Coverage Model Based Test Generation from Model Checking (project) Interaction of

Software Testing. Lecturer: Sebastian Coope Ashton Building, Room G.18

Software Quality Assurance. David Janzen

Announcements. Testing. Announcements. Announcements

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

MTAT : Software Testing

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

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

Written exam TDDD04 Software Testing

Path Testing + Coverage. Chapter 8

Topics in Software Testing

An Introduction to Systematic Software Testing. Robert France CSU

White-Box Testing Techniques

MTAT : Software Testing

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

CS111: PROGRAMMING LANGUAGE II

Software Engineering and Scientific Computing

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

10. Software Testing Fundamental Concepts

C07: Testing and JUnit

Program Analysis. Program Analysis

What is Structural Testing?

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

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

Chapter 9. Software Testing

Write perfect C code to solve the three problems below.

SFWR ENG 3S03: Software Testing

Getting those Bugs Out --Software Testing

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

MTAT : Software Testing

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

Introduction to Software Testing Chapter 3, Sec# 1 & 2 Logic Coverage

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

Darshan Institute of Engineering & Technology Unit : 9

People tell me that testing is

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

Chapter 14 Testing Tactics

MONIKA HEINER.

Testing Methods: White Box Testing I

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

MTAT Software Engineering

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

Introduction to Software Engineering

Approximate Transformations as Mutation Operators

Testing. UW CSE 160 Winter 2016

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

Lecture 15 Software Testing

Properties of Criteria. 1. Applicability Property. Criteria

Topic: Software Verification, Validation and Testing Software Engineering. Faculty of Computing Universiti Teknologi Malaysia

Darshan Institute of Engineering & Technology for Diploma Studies

Testing: Test design and testing process

Open Problems in Testability Transformation

Structural Testing. White Box Testing & Control Flow Analysis

Transcription:

Today CS 52 Theory and Practice of Software Engineering Fall 218 Software testing October 11, 218 Introduction to software testing Blackbox vs. whitebox testing Unit testing (vs. integration vs. system testing) Test adequacy Structural code coverage Statement coverage Decision coverage Condition coverage Mutation analysis Software testing What can testing do, and what can t it do? Software testing can show the presence of defects, but never show their absence! (Edsger W. Dijkstra) A good test is one that fails because of a defect. Two strategies: black box vs. white box Black box testing The system is a black box (can t see inside). No knowledge about the internals of a system. Create tests solely based on the specification (e.g., input/output behavior). White box testing Knowledge about the internals of a system. Create tests based on these internals (e.g., exercise a particular part or path of the system). How do we come up with good tests? Unit testing, integration testing, system testing Unit testing Does each unit work as specified? Integration testing Do the units work when put together? System testing Does the system work as a whole? Unit testing A unit is the smallest testable part of the software system. Goal: Verify that each software unit performs as specified. Focus: Individual units (not the interactions between units). Usually input/output relationships. Our focus: unit testing 1

Software testing Software testing can show the presence of defects, but never show their absence! (Edsger W. Dijkstra) A good test is one that fails because of a defect. Test effectiveness Ratio of detected defects is the best effectiveness metric! Problem The set of defects is unknowable Solution Use a proxy metric, for example code coverage When should we stop testing if no (new) test fails? Control Flow Graph (CFG) "Array numbers must not be null or double ; for (int i=; i<numbers.length; ) { if (d < ) { else { num < Statement coverage Every statement in the program must be executed at least once Given the control-flow graph (CFG), this is equivalent to node coverage "Array numbers must not be null or double ; for (int i=; i<numbers.length; ) { if (d < ) { else { 2

Structural code coverage: statement coverage Condition coverage vs. decision coverage num < Terminology Condition: a boolean expression that cannot be decomposed into simpler boolean expressions. Decision: a boolean expression that is composed of conditions, using or more logical connectors (a decision with logical connectors is a condition). Example: if (a && b) { a and b are conditions. The boolean expression a && b is a decision. Decision coverage (a.k.a. branch coverage) Every decision in the program must take on all possible outcomes (/) at least once Given the CFG, this is equivalent to edge coverage Example: if (a> && b>) a=1, b=1 a=, b= "Array numbers must not be null or double ; for (int i=; i<numbers.length; ) { if (d < ) { else { Structural code coverage: decision coverage Condition coverage Every condition in the program must take on all possible outcomes (/) at least once Example: (a> && b>) a=1, b= a=, b=1 num < 3

Structural code coverage: condition coverage "Array numbers must not be null or double ; for (int i=; i<numbers.length; ) { if (d < ) { else { num < Structural code coverage: subsumption Decision coverage vs. condition coverage Given two coverage criteria A and B, A subsumes B iff satisfying A implies satisfying B Subsumption relationships: Does decision coverage subsume statement coverage? Does decision coverage subsume condition coverage? Does condition coverage subsume decision coverage? 4 possible tests for the decision a b: 1. a =, b = 2. a =, b = 1 3. a = 1, b = 4. a = 1, b = 1 a b 1 a b 1 1 1 1 1 1 Satisfies condition coverage but not decision coverage a b a b 1 1 1 1 1 1 1 Does not satisfy condition coverage but decision coverage Neither coverage criterion subsumes the other! Structural code coverage: subsumption Code coverage: advantages Given two coverage criteria A and B, A subsumes B iff satisfying A implies satisfying B Subsumption relationships: Decision coverage subsumes statement coverage Decision coverage does not subsume condition coverage Condition coverage does not subsume decision coverage Code coverage is easy to compute. Code coverage has an intuitive interpretation. But, does coverage ensure effective testing? 4

Code coverage: drawbacks Code coverage does not require test assertions. Not all statements etc. are equally important. Coverage is not the same as behavior. Are there any alternatives? 5

Assumption: Mutant detection rate is a good proxy for fault detection rate. What does it mean for a test to fail on a mutant program? Mutation analysis: example Find a test case that detects the following mutant (i.e., passes on the original program but fails on the mutant) Mutation analysis: another example Find a test case that detects the following mutant (i.e., passes on the original program but fails on the mutant) Original program: public int min(int a, int b) { return a < b? a : b; Mutant: public int min(int a, int b) { return a; a b Original Mutant 1 2 1 1 1 1 1 1 2 1 1 2 Original program: public int min(int a, int b) { There is no such test that return a < b? a : b; can detect the mutant... The mutant is undetectable Mutant: because it is equivalent to public int min(int a, int b) { the original program! return a <= b? a : b; Summary Testing is an important way to measure code quality Black-box testing White-box testing Coverage metrics Statement Condition Decision Mutation-based metric For more, read: Are mutants a valid substitute for real faults in software testing? in FSE 214 6